Last active
December 6, 2017 16:53
-
-
Save ayuthmang/98e65c2a007c24984df8d3e706ee3ff7 to your computer and use it in GitHub Desktop.
TCPClient-TCPServer from Computer Networking A Top-Down Approach 6th Edition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socket import * | |
serverName = '127.0.0.1' | |
serverPort = 12000 | |
clientSocket = socket(AF_INET, SOCK_STREAM) | |
clientSocket.connect((serverName,serverPort)) | |
sentence = raw_input('Input lowercase sentence:') | |
clientSocket.send(sentence) | |
modifiedSentence = clientSocket.recv(1024) | |
print 'From Server:', modifiedSentence | |
clientSocket.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socket import * | |
serverPort = 12000 | |
serverSocket = socket(AF_INET, SOCK_STREAM) | |
serverSocket.bind(('127.0.0.1', serverPort)) | |
serverSocket.listen(1) | |
print 'The server is ready to receive' | |
while 1: | |
connectionSocket, addr = serverSocket.accept() | |
sentence = connectionSocket.recv(1024) | |
capitalizedSentence = sentence.upper() | |
connectionSocket.send(capitalizedSentence) | |
connectionSocket.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment