You can know more about sockets here.Īfter imports, we set up some constants for later use: clients = and then calls send(), which then works as expected. Clearly, TCP suit more to our purpose than UDP sockets, therefore we use them. ![]() We use them over UDP sockets because they’re more telephonic, where the recipient has to approve the incoming connection before communication begins, and UDP sockets are more post-mail sort of thing (anyone can send a mail to any recipient whose address s/he knows), so they don’t really require an establishment of connection before communication can happen. We will be using TCP sockets for this purpose, and therefore we use AF_INET and SOCK_STREAM flags. ![]() Here’s how we begin our server script (for this app, there are just two scripts: one for server and another for client): #!/usr/bin/env python3 """Server for multithreaded (asynchronous) chat application.""" from socket import AF_INET, socket, SOCK_STREAM from threading import Thread
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |