Overclock.net - An Overclocking Community - Reply to Topic

Thread: Does python have networking? Reply to Thread

Register Now

In order to be able to post messages on the Overclock.net - An Overclocking Community forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Please enter a password for your user account. Note that passwords are case-sensitive.
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:


  Additional Options
Miscellaneous Options

  Topic Review (Newest First)
08-17-2019 01:30 PM
Cloudforever you guys rock. Those links you've provided greatly helps.

12-11-2018 01:47 PM
PhotonFanatic A bit off topic, but it looks like learnpythonthehardway.org is just a site that sells a book. Am I missing anything here?
12-09-2018 11:03 PM
Python Networking

Python Networking Programs..

09-15-2015 11:26 AM
Mrzev Whenever i need to listen to a port for data and do something with it, I tend to go with python because it's pretty quick and easy. This script listens to port 5555 and writes the data into an SQL db.

import socket
import sys
import json
import mysql.connector
from datetime import datetime

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the port
server_address = ('', 5555)
print >>sys.stderr, 'starting up on %s port %s' % server_address
# Listen for incoming connections

print >>sys.stderr, 'Started - Listening'
while True:
        # Wait for a connection
        message = ""
        connection, client_address = sock.accept()
                print >>sys.stderr, 'connection from', client_address
                while True:
                        #Loops trough 1KB at a time until it received all the data.
                        data = connection.recv(1024)
                        message += data
                        if not data:                            
                                print message
                                print " "
                                jdata = json.loads(message)
                                cnx = mysql.connector.connect(user='', password='',
                                cursor = cnx.cursor()
                                type= jdata["MovementForward"][0]["Device"]["type"]
                                name = jdata["MovementForward"][0]["Device"]["name"]
                                x= jdata["MovementForward"][0]["Device"]["movements"][0]["Movement"]["points"][3]["PointLoc"]["x"]
                                y= jdata["MovementForward"][0]["Device"]["movements"][0]["Movement"]["points"][3]["PointLoc"]["y"]
                                date_object = datetime.strptime(jdata["MovementForward"][0]["Device"]["movements"][0]["Movement"]["date"], '%Y-%m-%dT%H:%M:%S+0000')

                                cursor.execute("INSERT INTO locations (type,name,x,y,dateReceived) VALUES (%s, %s, %s, %s, %s)",(type, name,x,y,date_object))

09-10-2015 06:58 PM
aldfig0 It means that by virtue of installing Python you've already got the standard library included. All you have to do is type "import socket" in your .py file and you can use everything in the socket module by typing socket. and the function name and arguments after the dot.

If you're clicking at things in your game instead of just typing in commands then your game uses a graphical user interface. If you want to do this note that Python has Tkinter built in its standard library which will easily allow you do create a GUI. You can also use third-party ones like PyQt, wxPython, or PyGame (which should have game-specific features but I've never used it so I can't be too sure).
09-10-2015 06:32 PM
Higgins909 ... rather confused with the word native attached to libraries. Does that mean I've got to learn another language? as that answer mentions c/c++ and normal dll and libs.
This is a example I was able to find that at least made some sense, but confused me on other parts.

This was in a java area.
"Native Library" generally means a non-Java library that's used by the system (so C/C++, etc). Think normal DLLs or libs.

What about graphics? Would it be called a gui in this case? I know linux has cli and gui versions... in a game is it called a gui still?
09-05-2015 09:04 PM
DuckieHo Sure... python has network libraries/modules natively....


Just learning to networked gaming is quite a big jump....
09-05-2015 08:54 PM
Higgins909 I'm trying to learn python from learnpythonthehardway.org and I'm about half way through.
I've looked at the index or whatever its called (don't know book terms) and it never mentions anything about networking. Only at the end does it say something like move onto ruby..

Does python have networking... Like I could make a game and have people connect over lan/wan?
Does ruby?


Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off