<reponame>etxahun/python_udp_tcp_sockets<filename>tcp_server_and_client/tcp_client.py
#! /usr/bin/env python

'''
    Simple TCP socket client
'''

import socket

TCP_IP = '127.0.0.1'
TCP_PORT = 5005
BUFFER_SIZE = 1024
MESSAGE = "Hello, World!"

# SOCK_STREAM for TCP socket type
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
data = s.recv(BUFFER_SIZE)
s.close()

print "received data:", data

#! /usr/bin/env python

'''
    Simple TCP socket client
'''

import socket

TCP_IP = '127.0.0.1'
TCP_PORT = 5005
BUFFER_SIZE = 1024
MESSAGE = "Hello, World!"

# SOCK_STREAM for TCP socket type
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
data = s.recv(BUFFER_SIZE)
s.close()

print "received data:", data
#! /usr/bin/env python Simple TCP socket client # SOCK_STREAM for TCP socket type