I have this script that, when it's restarted (forced), it prints a different IP/port of connection (using socket module). The thing is: a want a permanent connection (sure, when it doesn't restart). The function bind works exactly with this purpose?
Asked
Active
Viewed 1,551 times
1 Answers
0
Sockets are the interface between the application layer and the lower levels (transport layer and network layer) on the web stack. In order for a socket to communicate, it must be assigned an IP address and corresponding port number. This is done using socket.bind
. If bind
is not explicitly called, default values are assigned (the host machine IP and an unused port #).
Sockets are usually bound to an explicit address only on the server side (so the sending side can know what address to send messages to).

RandomHash
- 669
- 6
- 20

cs95
- 379,657
- 97
- 704
- 746
-
Is that possible to code in other to make client-side work as server-side too, in order to make a stable two-way communication? – CSS Monteiro May 14 '18 at 02:26
-
@TheInvertibleHogDog Yes, you can bind the address to the client if you wanted but it really doesn't matter, because the server will know the client's address when the client sends it a message anyway. – cs95 May 14 '18 at 02:27