Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have done some research (over <em>several</em> hours) and have found some solutions to my issues!</p> <p><strong>3:</strong> Yes, There is a way to have the clients communicate with each other, <em>they just have to use the server!</em> You have to initialize an infinite loop on the server side, which will receive data and send it. This is how I solved the issue:</p> <pre><code> while True: #Receiving from client data = conn.recv(1024) if not data: break conn.sendall(data) print data #To come out of the loop conn.close() </code></pre> <p>This program is part of a definition called <strong>clientthread</strong> which initializes all connections with clients. The "Actual" loop carries on the rest of the thread:</p> <pre><code> while True: #Wait to accept a connection - blocking call conn, addr = s.accept() #display client information (IP address) print 'Connected with ' + addr[0] + ':' + str(addr[1]) #Start new thread takees 1st argument as a function name to be run, second #is the tuple of arguments to the function start_new_thread(clientthread ,(conn,)) </code></pre> <p><strong>4:</strong> Yes, it will work between OS's. Sockets are <em>independent</em> of the platform. </p> <p><strong>6:</strong> That line of code is actually quite simple. The line <code>print channel.recv ( 100 )</code> tells the server to print the user input, up to 100 characters. The next line, <code>channel.send ( 'Green-eyed monster.' )</code> is simply telling the server to send out a message, <code>Green-eyed monster</code> to the client. </p> <p><strong>7:</strong> That error occurs because you cannot have more than one socket open per port. I would suggest using a line such as <code>s.close()</code> or <code>sys.exit()</code> at the end of your code, to close the port. Or you can simply choose another one!</p> <p><strong>8:</strong> There are some great tutorials out on the internet. One that teaches you the basics of sockets is <a href="http://www.binarytides.com/python-socket-programming-tutorial/1/" rel="nofollow">this</a>. Telnet was really confusing for me, so I discovered that in conjunction with <a href="http://www.devshed.com/c/a/Python/Sockets-in-Python/2/" rel="nofollow">this</a> client one can create a customized client which is in fact much better. </p> <p>If you have any questions, feel free to comment and I will try to answer.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload