| | |
Simple server problem
![]() |
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?
| Thread Tools | Search this Thread |
advanced aliased argv bash beginner bits calling casino changecolor clear command convert corners count csv cturtle cursor def definedlines dictionary digital dynamic dynamically enter event events examples external file float format frange function google gui hints homework i/o iframe import input jaunty java keyboard line linux list lists loop matching mouse multiple newb number numbers obexftp output parsing path port prime programming projects py py2exe pygame pygtk python random rational raw_input recursion return scrolledtext signal singleton skinning string strings tails terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 valueerror variable voip web-scrape whileloop word wxpython





