Created
August 1, 2011 17:42
-
-
Save qoelet/1118611 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Example of a TCP/IP Client in .NET # | |
# Tested on Mono/IronPython # | |
# imports | |
from System.Net.Sockets import * | |
from System.IO import * | |
HOST = "127.0.0.1" | |
PORT = 31000 | |
if __name__ == "__main__": | |
client = TcpClient(HOST, PORT) | |
s = client.GetStream() | |
sr = StreamReader(s) | |
sw = StreamWriter(s) | |
sw.AutoFlush = True | |
sw.WriteLine("hello server!") | |
print sr.ReadLine() # print response from server to screen | |
s.Close() | |
client.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment