No connection could be made because the target machine actively refused it
What shall I do to convince the target machine not to refuse it the next time
I used a
sock.Connect(serverEndPoint);
statement.Thanks
sock.Connect(serverEndPoint);
statement.
No connection could be made because the target machine actively refused it
mark baran
Thanks.
Fabio Miguez
I just ordered a Windows Server TCP/IP Reference book you've mentioned and a host of others at Amazon.com.
No matter how many books we read we will keep asking stupid questions though.
Xin Jin
while (totalBytesRcvd < byteBuffer.Length)
{ if ((bytesRcvd = sock.Receive(byteBuffer, totalBytesRcvd,
byteBuffer.Length - totalBytesRcvd, SocketFlags.None)) == 0)
{Console.WriteLine("Connection closed prematurely.");
break;
}
totalBytesRcvd += bytesRcvd;
}
FastLiveHelp
What is the size of the buffer you are reading the data into If the size of the buffer is larger than the size of the data that the server is going to send, then the receive call will block once it has read all of the data the server is sending.
In other words: If you buffer is 128 bytes long and the server is only sending 124 bytes, then you will read the 124 bytes from the server and then issue another Receive call waiting for the remaining 4 bytes that you think the server is going to send (which the server will never send). This could result in an apparent hang due to the fact that the client and server aren't in agreement of how much data is being transmitted. You could try setting the ReceiveTimeout on the client socket.
In V2.0 there is a ReceiveTimeout property. In previous versions you can call
socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReceiveTimeout, timeoutValue);
mydarlingdarla
HI Guys
It's very easy. please first understand, what will to do try. u try send a byte of data server to Client cliet to Server. So those two type of work, whether one is Do the Job as the receiver. So
We must Start that Receiver , rather than start the Sender.
if u confuse.
Please start Server first,
after start Client Do
it's work.
tnx Guys.,
Wazoo
Patrick Verleysen
1. The receive is a blocking call. Is the other end sending...
2. Did you initialize totalBytesRcvd to 0
BubbaHasty
I can answer the first question with 85% certainty only. A system process Winnt\system32\MStask.exe was attached to this port and I realized a few minutes after I posted this that probably the other side was either not sending anything or the process was attached to this port as a perfunctory measure for some unknown contingencies.
Those dynamic considerations escape newbies, as you know. It takes time.
I will make sure there is a full duplex communication via a port next time.
Thanks.
thatKid
you mentioned. It could also mean that there is a firewall of some sorts that is
not allowing incoming connections on that port eventhough you might have a server listening on that port
2drunk2funk
while
(totalBytesRcvd < byteBuffer.Length){ if ((bytesRcvd = sock.Receive(byteBuffer, totalBytesRcvd,
byteBuffer.Length - totalBytesRcvd, SocketFlags.None)) == 0)
{Console.WriteLine("Connection closed prematurely.");
break;
}
totalBytesRcvd += bytesRcvd;
} At the IF statement the program stopped responding (in debug) for unknown reason and without giving me any identifyable error message or demand for Console input. 11 bytes were sent to the server. Any insight please