Return to Snippet

Revision: 66291
at April 12, 2014 02:33 by JordanRowles


Updated Code
# SocketServer_Client.py
# Version: 1.0
# Use: Internal Application (Work)
# Purpose: Client-side code for sending information to the server.
# Copyright (C)2014 Jordan Rowles
# GNU General Public License Version 3 or Later

import socket
import sys

HOST, PORT = 'localhost', 9999
DATA = " ".join(sys.argv[1:])
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try:
    sock.connect((HOST, PORT))
    sock.sendall(DATA+"\n")
    received = sock.recv(1024)
finally:
    sock.close()

print "    Sent: {}".format(DATA)
print "Received: {}".format(received)

Revision: 66290
at April 12, 2014 01:31 by JordanRowles


Updated Code
# SocketServer_Client.py
# Version: 1.0
# Use: Internal Application (Work)
# Purpose: Client-side code for sending information to the server.
# Copyright (C)2014 Jordan Rowles
# GNU General Public License Version 3 or Later

import socket
import sys

HOST, PORT = 'localhost', 9999
DATA = " ".join(sys.argv[1:])
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try:
    sock.connect((HOST, PORT))
    sock.sendall(DATA+"\n")
    received = sock.recv(1024)

print "    Sent: {}".format(DATA)
print "Received: {}".format(received)

Revision: 66289
at April 12, 2014 01:24 by JordanRowles


Initial Code
import socket
import sys

HOST, PORT = 'localhost', 9999
DATA = " ".join(sys.argv[1:])
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try:
    sock.connect((HOST, PORT))
    sock.sendall(DATA+"\n")
    received = sock.recv(1024)

print "    Sent: {}".format(DATA)
print "Received: {}".format(received)

Initial URL
SocketServer-Client

Initial Description
Client code for sending information to the logging server.

Initial Title
SocketServer_Client.py

Initial Tags
data, server

Initial Language
Python