Address already in use… sockets in C

后端 未结 2 718

This question has been asked before, yet I just can\'t seem to come to grips with it as small details of all the questions ive ever seen throw me off...

I keep having is

2条回答
  •  一整个雨季
    2021-01-26 16:40

    Yes, the relevant socket option is called SO_REUSEADDR. You use setsockopt() to set socket options.

    You should normally not close the server's main socket though, instead you should use accept() to create per-client sockets, which can be closed when the client disconnects.

提交回复
热议问题