| | |
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: 288 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Python
alarm aliased application beginner calculator casino character code command cx-freeze definedlines development dictionary dynamic error event examples excel exe file filename float format ftp function google graphics gui homework ideas import input java launcher line linux list lists logging loop matching microphone mouse movingimageswithpygame newb number numbers obexftp output parsing path permissions phonebook pointer port prime program programming projects py2exe pygame pyglet pyqt pysimplewizard python random recursion recursive refresh return reverse scrolledtext shebang simple skinning sprite ssh statistics string strings table terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 valueerror variable voip windows wxpython xlib





