ups sorry, I just forgot to write in English
ok, here is my question in english:
I am writing a program in c# and am using a UdpClient to send packages with
data over the network
to a server. Each time, I first send a request to the server and then I
receive an answer.
But until now I could not discover how to set the timeout.
Does anybody know how to do that?
Every now and then a package gets lost and this is when I do not receive an
answer and the program hangs up.
Here is a code snippet:
....Code...
[quoted text, click to view] >
> Client = new UdpClient(IP, Port);
>
> ...Code...
>
> int nByteSent;
>
> byte[]inputToBeSent= new byte[50];
>
> nBytesSent = Client.Send(inputToBeSent,inputToBeSent.Length);
>
> ...Code..
>
> IPHostEntry remoteHostEntry = Dns.GetHostByName(IP);
>
> IPEndPoint remoteIpEndPoint = new
IPEndPoint(remoteHostEntry.AddressList[0],
> Port);
>
> received = Client.Receive(ref remoteIpEndPoint);
>
>
Thank you for every hint
"Karolin Spill" <KSpill@ADwin.de> schrieb im Newsbeitrag
news:bj28te$inf$00$1@news.t-online.com...
[quoted text, click to view] > Hallo NG,
>
> ich schreibe ein Programm in c# und benutze einen UdpClient, um
Datenpackete
> übers Netzwerk an einen Server zu schicken. Dabei erfolgt immer erst eine
> Anfrage vom Client an den Server und der Server schickt dann eine
Antwort.
> Ich habe jedoch bis jetzt nicht herausgefunden, wie ich ein Timeout
setzen
> kann.
> Weiß jmd, wie man das macht?
> Ab und zu scheint nämlich ein Paket verloren zu gehen und wenn ich dann
> keine Antwort bekomme, dann
> hänge ich in der Receive-Funktion fest. Dann geht garnichts mehr.
> Hier ist ein CodeSchnipsel:
>
> ...Code...
>
> Client = new UdpClient(IP, Port);
>
> ...Code...
>
> int nByteSent;
>
> byte[]inputToBeSent= new byte[50];
>
> nBytesSent = Client.Send(inputToBeSent,inputToBeSent.Length);
>
> ...Code..
>
> IPHostEntry remoteHostEntry = Dns.GetHostByName(IP);
>
> IPEndPoint remoteIpEndPoint = new
IPEndPoint(remoteHostEntry.AddressList[0],
> Port);
>
> received = Client.Receive(ref remoteIpEndPoint);
>
>
>
> Bin dankbar für jeden Hinweis
>
>
>