Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I'm using WinSock in C# to send some data to a server(duh). The problem is that I have a loop that does some things other then sending data. After some time, about 10-15 times sending, I get this error:

 

An established connection was aborted by the software in your host machine

 

How can I work around this? I know that it probably has something to do with timeouts, but where can I change those settings?

For questions about VS .net extensibility, please fire at me! :)

For readability, please use the [ CS][/CS ] tags

Posted

[CS]

for(int i = 0; i <= 31; i++ )

{

 

for(int idx=0;idx<16;idx++)

{

for(int idx2=0;idx2<=i;idx2++)

{

cookie = //some datatests

 

buffer = "HEAD /PATH HTTP/1.1\r\n"; //

buffer += "Host: SERVER\r\n";

buffer += "Cookie: " + cookie + "\r\n";

buffer += "Connection: close\r\n";

buffer += "\r\n";

 

buffer2 = Encoding.ASCII.GetBytes(buffer);

s.Send(buffer2,buffer2.Length,0);

//Error above @ s.Send() <--

 

int counter = 1;

while (counter > 0)

{

counter = s.Receive(bytes, bytes.Length, 0);

header = header + Encoding.ASCII.GetString(bytes, 0, counter);

}

 

 

if(header.IndexOf("LOCATION\r\n",0,header.Length) == -1)

{

//Do Stuff

}

 

}

}

 

//Reset stuff

}

[/CS]

For questions about VS .net extensibility, please fire at me! :)

For readability, please use the [ CS][/CS ] tags

Posted
*bumps the topic*

For questions about VS .net extensibility, please fire at me! :)

For readability, please use the [ CS][/CS ] tags

  • Administrators
Posted

Out of interest what makes you suspect a timeout is causing the problem?

What is running on the remote service (I'm guessing it is a webserver) and are you sure you are sending the correctly formatted requests to it?

If you output your requests to a debugger do the ones that break the app still appear to be correct and valid?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...