473,563 Members | 2,897 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Client-Server problem: sending udp packets to server causes "an existing connection was focibly closed by the remote host"

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(sendBy tes, sendBytes.Lengt h);

System.Net.IPEn dPoint RemoteIpEndPoin t = new
System.Net.IPEn dPoint(System.N et.IPAddress.An y, 0);

Byte[] receiveBytes = udp.Receive(ref RemoteIpEndPoin t);
string returnData = Encoding.ASCII. GetString(recei veBytes);

MessageBox.Show (returnData.ToS tring());
udp.Close();
}
catch (Exception problemo ) {
MessageBox.Show (problemo.Messa ge);
}
}
any help would be much appreciated

Thanks

--Dave


Nov 16 '05 #1
0 1637

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1365
by: ashima | last post by:
Hi, I am trying to add a webservice.I provide a reference to the wsdl file on the server. It works fine when I compile the code on my machine. But on the server, I get the above error with the same compiled code. UNDERLYING CONNECTION WAS CLOSED.REMOTE NAME COULD NOT BE RESOLVED. I read some of the articles which indicate a problem with the...
22
3246
by: Kristof Thys | last post by:
Hello, I'm developing a C# - windows forms application. To get some information for my application, I'm connecting to an URL, wich gives me XML generated using php. With 90% of the users, this code just works fine: WebRequest request = WebRequest.Create(URL);
0
2390
by: Mike | last post by:
VB .NET 2003, Pocket PC 2003, CF 1.0 SP 2 Only when I use a proxy server, I'm getting this error when attempting to write data to a Stream object from an HTTPWebRequest object. (System.IO.Stream.Write() raises the exception):"An existing connection was forcibly closed by the remote host". The error only happens with fairly large amounts of...
26
16484
by: Rajeev Tipnis | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en- us;819450 Questions: 1) Is this patch (fix) applicable to the .NET 1.1 Framework as well? That is, if we have Framework 1.1 (On Win2K3/IIS6.0), do we still need this patch? 2) Does it specifically solve only this error: The underlying connection was closed. An unexpected error
0
1201
by: Sanjay T | last post by:
Hi, We are using ASP.Net 2005 and SQL Server 2005. We are storing sessions in the database. From time to time we get the following exception in the application while the ASP.Net session tries accessing the database. This also happens from time to time when our application is accessing the database. To make the posting brief, I am just...
0
2055
by: imonline | last post by:
Hi, I have created a asp.net page which posts XML on the web service using .net 2.0. The page and the webservice was working fine but once I converted them to .net 3.5 I have been getting following exception. And I am having this problem on the local machine that is both of them on same machine. Exception: System.Net.WebException was...
2
3895
by: OrcaDK | last post by:
Hi I've started receiving sporadic SqlExceptions throughout my .NET applications (crossing ASP.NET, Windows Services, Winforms - doesn't seem application code specific): System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was...
0
2557
by: meetvishu1 | last post by:
I am useing wcf with c# below is the error i found when i try to save the record twice ,at first time it works fine. It is also reproduce randomly once for the second time i hit save next time for nth time below is the description of error with stack trace , and piece of code which are having excetion. ...
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.