Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

UDP Timeout

PaulDPaulD Member Posts: 5
I am writing a client for our local Postocde server. The Client has to send and receive address information to and from the server. The server runs under UDP. I can successfully send strings to the server but if for whatever reason the server does not reply my program will have indefinately. I have tried the folloing:

Try
receiveBytes = PCClient.Receive(RemoteIpEndPoint)
Catch l As Exception
MsgBox("Error Connecting to Postcode Server", MsgBoxStyle.Critical, "Postcode server error")
End Try

but the receivebytes line does not appear to generate any kind of exception....it just hangs on the line.

When I step through the code, because I step through slower than if it was executing the server has usually replied by the time I get to this line.

Does anyone have any ideas/solutions to stop the program hanging when it doesn't receive data??

Thanks in Advance

Comments

  • DrMartenDrMarten Member Posts: 748
    [b][red]This message was edited by DrMarten at 2006-10-27 4:50:5[/red][/b][hr]
    : I am writing a client for our local Postocde server. The Client has to send and receive address information to and from the server. The server runs under UDP. I can successfully send strings to the server but if for whatever reason the server does not reply my program will have indefinately. I have tried the folloing:
    :
    : Try
    : receiveBytes = PCClient.Receive(RemoteIpEndPoint)
    : Catch l As Exception
    : MsgBox("Error Connecting to Postcode Server", MsgBoxStyle.Critical, "Postcode server error")
    : End Try
    :
    : but the receivebytes line does not appear to generate any kind of exception....it just hangs on the line.
    :
    : When I step through the code, because I step through slower than if it was executing the server has usually replied by the time I get to this line.
    :
    : Does anyone have any ideas/solutions to stop the program hanging when it doesn't receive data??
    :
    : Thanks in Advance
    ----------------------------------------------------------------------

    Hi,

    You could start a timer as a 2nd process and get the timer to close the connection if it reaches a certain time like 10 or 20 seconds perhaps?

    How you would go about doing this i'm not entirely sure.
    Type [b][blue]VB.Net forum[/blue][/b] into the search box on www.microsoft.com and trying asking in a forum on there too if you like.

    This is the usual method or way that I.S.P. servers work so that they don't hang if your computer is switched off or loses it's connection.


    Regards,

    Dr M.
Sign In or Register to comment.