| | |
Simple server problem
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
oops! sorry. anyways...
i'm a little fuzzy on all this socket server stuff, so try to bear with me. I want to users to be able to connect to each other. the code for my server is:
and for my 'client':
so how does a server really work? mine doesn't really work when I run it.
i'm a little fuzzy on all this socket server stuff, so try to bear with me. I want to users to be able to connect to each other. the code for my server is:
Python Syntax (Toggle Plain Text)
import socket socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) socket.bind(( "", 1024 )) print "Bind socket to: 1024..." socket.listen(2) # Listen for connections made to the socket; can support 2, as we specified conn, addr = socket.accept() # accepts connection while 1: # infinite while loop print 'Running?' data = conn.recv(1024) if not data: break conn.send(data)
and for my 'client':
Python Syntax (Toggle Plain Text)
import socket socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) socket.connect(1024) os.system("pause")
so how does a server really work? mine doesn't really work when I run it.
![]() |
Similar Threads
- how would you apply threading to a web server application (C++)
- Client-Server problem - send timestamp (C)
- multi-client server [problem with code - please have a look] (Java)
- help with simple server prog (C)
- File Upload To Server - Problem (ASP)
- Simple question (Python)
- Help with Infostealer and Trojan.Metajuan (Viruses, Spyware and other Nasties)
- Windows server 2003 User creation problem (Windows NT / 2000 / XP)
- Datagrid inside repeater-simple reference problem (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
Other Threads in the Python Forum
- Previous Thread: Any Idea on Media Player Library/Module
- Next Thread: Using a list as values in a dictionary?
Views: 289 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied address ansi backend beginner changecolor class code conversion coordinates copy corners curves customdialog dan08 dictionary digital dynamic editing events examples excel file float font format ftp function generator getvalue gui halp handling homework i/o iframe import input java line linux list lists loop mouse mysql newb number numbers numeric output parameters parsing path port prime program programming progressbar projects py py2exe pygame pyqt python random rational recursion recursive schedule screensaverloopinactive scrolledtext searchingfile server ssh stamp statictext string strings table tails terminal text thread threading time tkinter tlapse tuple tutorial type ubuntu unicode url urllib urllib2 variable windows write wxpython





