dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 25

Thread: socket programming error

  1. #1
    Join Date
    Sep 2011
    Posts
    11

    Question socket programming error

    hi

    how can i fix error 10054 "An existing connection was forcibly closed by the remote host" ?
    i write a program with c# , that should send a message to other pc with udp protocol , when I run the program , this error occurred !
    I thank u , if u can solve this problem

  2. #2
    Join Date
    Mar 2001
    Posts
    2,527

    Re: socket programming error

    Sounds like the remote host is having a memory exception as a result of the message that it is receiving somehow. After you send this message what happens to the client on the remote host?
    ahoodin
    To keep the plot moving, that's why.

  3. #3
    Join Date
    Sep 2011
    Posts
    11

    Re: socket programming error

    this error is in the client side and stop it , server just runing and wait for client .

    do u know why this problem has occurred ?
    can this related to port number i used or cause of windos accessibility ... I don't know ! but I need too fix it !!
    I can give the codes , if it is necessary.

  4. #4
    Join Date
    Mar 2001
    Posts
    2,527

    Re: socket programming error

    Most likely the client sends a message to the server, the server sends back a response, but the client can't handle the response data and dies.

    This could be because the server response is not correct, or because the client code to handle the response is not correct.

    from the MSDN:
    WSAECONNRESET 10054
    An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket). This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.
    ahoodin
    To keep the plot moving, that's why.

  5. #5
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,331

    Re: socket programming error

    Is the server/router set to allow UDP on the given port?
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Mar 2001
    Posts
    2,527

    Re: socket programming error

    AAaah this is a good point, is the router configured to allow comms on the port?
    ahoodin
    To keep the plot moving, that's why.

  7. #7
    Join Date
    Sep 2011
    Posts
    11

    Re: socket programming error

    just asking about allow the program to run , nothing about the port !
    but i check the port i used , it's open !

  8. #8
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,331

    Re: socket programming error

    The port is important. Is the server you are connecting to written by you as well? Is it on the same LAN? Your message indicates that your attempt to send UDP was effectively booted by the receiver.
    Always use [code][/code] tags when posting code.

  9. #9
    Join Date
    Mar 2001
    Posts
    2,527

    Re: socket programming error

    Better check your firewall. Complaining about it won't help!

    ahoodin
    To keep the plot moving, that's why.

  10. #10
    Join Date
    Sep 2011
    Posts
    11

    Re: socket programming error

    about the program and port , I use port number 9050 and it is open in my pc.
    and i should say that I try another program ( with this purpose) , and it has a same problem! so i think this isn't related to codes.
    about the LAN , yes they are on the same and I set right IP .
    and firewall , i turned it off ! (in "windows firewall with advanced security" / "windows firewall propertiese"/ turned off domain,private,public profiles)

  11. #11
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,331

    Re: socket programming error

    So both programs are running on the same pc ?
    Always use [code][/code] tags when posting code.

  12. #12
    Join Date
    Sep 2011
    Posts
    11

    Re: socket programming error

    yeah , try them on same pc.

    about the ports , i have a question : is there a special port num for sending text message in udp ? or not , i can use any port , just open port ?!

  13. #13
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,331

    Re: socket programming error

    It's been a very long time since I have did anything at all with UDP. I use TCP for all communications now. I can't remember if there was any issues with running 2 UDP programs on the same PC or not.

    There is no special port, just needs to be one that is available.

    You still have not told us if the program you are sending to is a program written by you or someone else. If you have the code then it would be good to see what happens there when you send a message, for example does a received event fire? If the program was not written by you are you sure it accepts UDP transmissions? Have you tried it on a different PC from your client?
    Always use [code][/code] tags when posting code.

  14. #14
    Join Date
    Mar 2001
    Posts
    2,527

    Re: socket programming error

    Hmmm well #

    1 just because both apps are on the same PC doesn't mean the firewall aint in the way. What address are you sending the packets too? Your IP or "127.0.0.1" or are you using a DNS function?

    #2 Better post some source code, otherwise you get to hear all our fancy guesswork.

    When you do post your code, put it in code tags.

    It is an icon that looks like # between the <> icon and the quote icon.
    Code:
    void main (void)
    {
    //...
    }
    HTH,
    ahoodin
    To keep the plot moving, that's why.

  15. #15
    Join Date
    Sep 2011
    Posts
    11

    Re: socket programming error

    to DataMiser : no i don't write the program and about UDP transmission how can i know this ?!
    yeah i should try it on other PC...

    to ahoodin :
    tnx for fancy guesswork ! i totally listen to them
    about the address , use 127.0.0.1
    and i don't understand u , what's code tag ?!

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)