Client-Server problem: sending udp packets to server causes "an existing connection was focibly closed by the remote host"
From: Bigdave (spam_at_spamm.com)
Date: 02/06/05
- Next message: Michael C#: "Re: New Promotion, need advice"
- Previous message: pachanga: "New Promotion, need advice"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 6 Feb 2005 03:46:33 -0000
hi
Ive recently started coding a small project in c# using microsofts 2005
beta, i am trying to setup a small application that will send a string to a
server via udp, then for that same app to listen for a response from the
server and write the response into a message box, but when testing this on
the loopback address (127.0.0.1) i recieve "an existing connection was
focibly closed by the remote host", i have wrote the following code:
private void test_butt_Click(object sender, EventArgs e)
{
string ip = ip_txt.Text;
try
{
UdpClient udp = new UdpClient();
udp.Connect(ip, 29119);
Byte[] sendBytes = Encoding.ASCII.GetBytes("Is anybody
there?");
udp.Send(sendBytes, sendBytes.Length);
System.Net.IPEndPoint RemoteIpEndPoint = new
System.Net.IPEndPoint(System.Net.IPAddress.Any, 0);
Byte[] receiveBytes = udp.Receive(ref RemoteIpEndPoint);
string returnData = Encoding.ASCII.GetString(receiveBytes);
MessageBox.Show(returnData.ToString());
udp.Close();
}
catch (Exception problemo ) {
MessageBox.Show(problemo.Message);
}
}
any help would be much appreciated
Thanks
--Dave
- Next message: Michael C#: "Re: New Promotion, need advice"
- Previous message: pachanga: "New Promotion, need advice"
- Messages sorted by: [ date ] [ thread ]