Reusing socket descriptor on connection failure

后端 未结 5 621
逝去的感伤
逝去的感伤 2020-12-19 00:38

In my client code, I am following these steps to connect to a socket:

  1. Creating a socket

    sockDesc = socket(PF_INET, SOCK_STREAM, IPPROTO_TC         
    
    
            
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-19 01:25

    Yes, you should close and go back to step 1:

    close() closes a file descriptor, so that it no longer refers to any file and may be reused.

    From here.

提交回复
热议问题