Ok so if i want to block any url's that include ex: "http://ad." from being sent via socket once requested by a client application. once i block that AD request from being sent out, do i have to send a socket of identical size(identical sizeof the AD) so the client doesnt keep asking for it? or how to i take care of that?
I am requesting pages for the client like this: -
System.Net.Configuration.HttpWebRequestElement wr = new System.Net.Configuration.HttpWebRequestElement();
-
wr.UseUnsafeHeaderParsing = true;
-
try
-
{
-
WebResponse response = (WebResponse)WebRequest.Create(url).GetResponse();
-
Stream responsestream = response.GetResponseStream();
-
Or, if the request from the client is an invalid request(cannot be resolved) how to i make the browser stop waiting for me to reply a response?
15 1385
Just that doesnt do it, it the client browser still thinks there is more coming so it waits...
here is the code format i use to send the 40x error:
sent with: SError (soket, 403, "Forbidden", "AD"); -
public void SError(Socket soket,int eNum, string eType, string eMessage)
-
{
-
SendMessage(soket, "HTTP/1.1" + " " + eNum + " " + eType + "\r\n");
-
SendMessage(soket, "Content-Type: text/plain" + "\r\n");
-
SendMessage(soket, "\r\n");
-
SendMessage(soket, eNum + " " + eType + "\r\n");
-
SendMessage(soket, eMessage + "\r\n");
-
}
-
private void SendMessage(Socket soket, string sage)
-
{
-
Byte[] duff = new Byte[sage.Length];
-
Int32 SeMESSAGE = Encoding.ASCII.GetBytes(sage, 0, sage.Length, duff, 0);
-
try
-
{
-
soket.Send(duff, SeMESSAGE, 0);
-
}
-
catch (Exception a)
-
{
-
Console.WriteLine("Error: {0}", a.Message);
-
}
-
}
-
I would like to send the message 403 and have the client browser stop working on the blocked request, how can i do so?
Well sending it the 403 error with correct header types, SHOULD have made it stop.
Try using the 404 error maybe?
Well sending it the 403 error with correct header types, SHOULD have made it stop.
Try using the 404 error maybe?
ive tried both, is my header format correct?
No sucess...im using foxfire3, and when ever i request ex: sadkjsadsafj.com my program recognizes that it isnt a real address and sends: -
private void SendMessage(Socket soket)
-
{
-
string sage="HTTP/1.0 404 File Not Found\n\r\n\r";
-
Byte[] fe = new Byte[0x400];
-
Int32 SeMessage = Encoding.ASCII.GetBytes(sage, 0, sage.Length, fe, 0);
-
try
-
{
-
soket.Send(fe, SeMessage, 0);
-
}
-
catch (Exception a)
-
{
-
Console.WriteLine("Error: {0}", a.Message);
-
}
-
}
-
but the browser just keeps waiting and waiting as if the page is going to load..
the \r needs to come first.
I also don't understand your socket code. What is all that buisness you are doing there?
I woulda just done this: -
private void SendMessage(Socket soket)
-
{
-
string sage="HTTP/1.0 404 File Not Found\r\n\r\n";
-
byte[] payload = Encoding.ASCII.GetBytes(sage);
-
try
-
{
-
soket.Send(payload);
-
}
-
catch (Exception a)
-
{
-
Console.WriteLine("Error: {0}", a.Message);
-
}
-
}
-
the \r needs to come first.
I also don't understand your socket code. What is all that buisness you are doing there?
I woulda just done this: -
private void SendMessage(Socket soket)
-
{
-
string sage="HTTP/1.0 404 File Not Found\r\n\r\n";
-
byte[] payload = Encoding.ASCII.GetBytes(sage);
-
s.Send(payload);
-
try
-
{
-
soket.Send(payload);
-
}
-
catch (Exception a)
-
{
-
Console.WriteLine("Error: {0}", a.Message);
-
}
-
}
-
how would i define "s"?
i just commented it out and now have this for testing: -
public void SendMessage(Socket soket)
-
{
-
string sage = "HTTP/1.0 404 File Not Found\r\n\r\n";
-
byte[] payload = Encoding.ASCII.GetBytes(sage);
-
//s.Send(payload);
-
try
-
{
-
soket.Send(payload);
-
}
-
catch (Exception a)
-
{
-
Console.WriteLine("Error: {0}", a.Message);
-
}
-
}
-
and firefox still waits on this
s.Send(payload) was a typeo, and shouldn't have been in here.
Have you used firebug in FF to see what is going on?
FF should be standards compliant and close itself.
You could try ammending the message to this:
string sage = "HTTP/1.0 404 File Not Found\r\nConnection: close\r\n\r\n";
Have you used firebug in FF to see what is going on?
FF should be standards compliant and close itself.
You could try ammending the message to this:
string sage = "HTTP/1.0 404 File Not Found\r\nConnection: close\r\n\r\n";
firebug is for html type. but i tried it anyways :)
ok well now when my program cant resolve the address it sends that amended string and firefox doesnt wait anymore!
we are making progress!
But... when i block the ad's and manually send the same amended 404; firefox continues to wait. why doesnt it work here?
Well, you could also CLOSE the socket, that would also get FF to stop waiting.
also, firebug does like everything.
it will tell you every request/response made for the page.
so if you load a page with 4 pictures and one linked CSS file, it will show you all the requests/responses for those 4 pictures and the css file.
i was hoping for a way to accomplish this without closing the socket (althought the way i coded my programming closing the socket wouldnt be a big deal- i dont think)
I'll give it a try, and also play around with firebug some more.
Closing the socket works! - thank you :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chuck E. Cheese |
last post by:
I need a php page to connect to a python created socket and sent and
receive data. below is the python code which opens a socket on the
localhost @ port 21567:
#!/usr/bin/python2
from socket...
|
by: simon place |
last post by:
Spent some very frustrating hours recoding to find a way of closing a server
socket, i'd not thought it would be any problem,
however, after complete failure and as a last resort, i looked at the...
|
by: Thomas Hervé |
last post by:
My problem is not really python specific but as I do my implementation
in python I hope someone here can help me.
I have two programs that talk through a socket. Here is the code :
<server>...
|
by: DreJoh |
last post by:
I've read many articles on the subject and the majority of them give the same
solution that's in article 821625 on the MSDN website. I'm using the
following code and when a the client disconnects...
|
by: Chris Tanger |
last post by:
Context:
C#
System.Net.Sockets
Socket created with constructor prarmeters Internetwork, Stream and TCP
everything else is left at the default parameters and options except linger
may be changed...
|
by: Macca |
last post by:
Hi,
I am writing an asychronous socket server to handle 20+ simulataneous
connections.
I have used the example in MSDN as a base. The code is shown at end of
question.
Each connection has a...
|
by: BuddyWork |
last post by:
Hello,
Could someone please explain why the Socket.Send is slow to send to the same
process it sending from. Eg. Process1 calls Socket.Send which sends to the
same IP address and port, the...
|
by: darthghandi |
last post by:
I've created a class to listen to all interfaces and do a
BeginAccept(). Once it gets a connection, it passes the connected
socket off and stores it in a List. Next, it continues to listen for...
|
by: O.B. |
last post by:
I have a socket configured as TCP and running as a listener. When I
close socket, it doesn't always free up the port immediately. Even
when no connections have been made to it. So when I open...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |