Send a particular packet with this python client

Sbaush sbaush at gmail.com
Tue Jan 24 15:36:36 CET 2006


I can specify the question, so you can request me easily...
The int should be an integer of 32 bit fixed. This is total packet size. The
string should contain XML.
In this example the string is taken from keyboard, so for example.
Thanks all for your helps...

2006/1/24, Sbaush <sbaush at gmail.com>:
>
> Hi all, i have a python udp client/server.
> I would send a packed like this: |int|string| . How can i do it with tih
> client?
> Another question: buf is the total packet size?
>
> from socket import *
> *# Set the socket parameters*
> host = "192.168.11.49"
> port = 21567
> buf = 1024
> addr = (host,port)
> *# Create socket*
> UDPSock = socket(AF_INET,SOCK_DGRAM)
>
> def_msg = "===Enter message to send to server===";*print* "\n",def_msg
>
> *# Send messages**while* (1):
> 	data = raw_input('>> '
> )
> 	*if* *not* data:
> 		*break*
> 	*else*:
> 		*if*(UDPSock.sendto(data,addr)):
> 			*print* "Sending message '",data,"'.....<done>"
> *# Close socket*UDPSock.close()
>
>
>
>
> --
> Sbaush




--
Sbaush
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060124/ba0df76a/attachment.html>


More information about the Python-list mailing list