# An example script to connect to Google using socket import socket # for socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except socket.error as err: print 'socket creation failed with error %s' % (err) # default port for socket host_ip = socket.gethostbyname( 'www.google.com' ) print 'there was an error resolving the host' s.connect((host_ip, port)) print 'the socket has successfully connected to google |
import socket # next create a socket object print 'Socket successfully created' # reserve a port on your computer in our port = 12345 # Next bind to the port # instead we have inputted an empty string # coming from other computers on the network print 'socket binded to %s' % (port) # put the socket into listening mode print 'socket is listening' # a forever loop until we interrupt it or while True : # Establish connection with client. print 'Got connection from' , addr # send a thank you message to the client. c.close() |
import socket # Create a socket object port = 12345 # connect to the server on local computer print s.recv( 1024 ) s.close() |
NONE
to '.'
, not a space. Then, you could make such a print function for the board: