Skip to content

Instantly share code, notes, and snippets.

@qoelet
Created August 1, 2011 17:42
Show Gist options
  • Save qoelet/1118611 to your computer and use it in GitHub Desktop.
Save qoelet/1118611 to your computer and use it in GitHub Desktop.
# 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