I have used the pickle function in python for a socket proogramming question. But the ouput I receive at the server is printed as "<main.ProcessData instance at 0x7fbacba37f38>" instead of what is sent.
The Server and Client code are as follows:
SERVER
import socket, pickle
class ProcessData:
print "Server is Listening....."
print "Server is Listening....."
HOST = 'localhost'
PORT = 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
data = conn.recv(4096)
data_variable = pickle.loads(data)
conn.close()
print data_variable
print 'Data received from client'
CLIENT
import socket, pickle
class ProcessData:
print 'ABCDEFGHIJK'
HOST = 'localhost'
PORT = 50007
# Create a socket connection.
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
# Create an instance of ProcessData() to send to server.
variable = ProcessData()
# Pickle the object and send it to the server
data_string = pickle.dumps(variable)
s.send(data_string)
s.close()
print 'Data Sent to Server'
I Am getting the following output:
Server is Listening..... Server is Listening..... Connected by ('127.0.0.1', 34726) <main.ProcessData instance at 0x7f8e2dfaaf80> Data received from client
But I have to get ABCDEFGHIJ. What should I do?