473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

python socket programming...

hi,
can anyone tell me how to receive the data from a particular sender using the recvfrom system call in python????

i need the syntax(prototype) of the recvfrom call in python...

if possible please give me an example...
Mar 4 '08 #1
5 1619
amitpatel66
2,367 Expert 2GB
This issue is related to Python, so moved this thread to Python forum
Mar 4 '08 #2
hi,
can anyone tell me how to receive the data from a particular sender using the recvfrom system call in python????

i need the syntax(prototype) of the recvfrom call in python...

if possible please give me an example...
from socket import *
Expand|Select|Wrap|Line Numbers
  1. # Set the socket parameters
  2. host = "localhost"
  3. port = 21567
  4. buf = 1024
  5. addr = (host,port)
  6.  
  7. # Create socket and bind to address
  8. UDPSock = socket(AF_INET,SOCK_DGRAM)
  9. UDPSock.bind(addr)
  10.  
  11. # Receive messages
  12. while 1:
  13.     data,addr = UDPSock.recvfrom(buf)
  14.     if not data:
  15.         print "Client has exited!"
  16.         break
  17.     else:
  18.         print "\nReceived message '", data,"'"
  19.  
  20. # Close socket
  21. UDPSock.close()
Mar 4 '08 #3
wat if i want to receive the data from a particular client whose address is known???
i want to receive data from a particular client whose address is known...
wat other arguments should i add to tat system cal??



from socket import *
Expand|Select|Wrap|Line Numbers
  1. # Set the socket parameters
  2. host = "localhost"
  3. port = 21567
  4. buf = 1024
  5. addr = (host,port)
  6.  
  7. # Create socket and bind to address
  8. UDPSock = socket(AF_INET,SOCK_DGRAM)
  9. UDPSock.bind(addr)
  10.  
  11. # Receive messages
  12. while 1:
  13.     data,addr = UDPSock.recvfrom(buf)
  14.     if not data:
  15.         print "Client has exited!"
  16.         break
  17.     else:
  18.         print "\nReceived message '", data,"'"
  19.  
  20. # Close socket
  21. UDPSock.close()
Mar 5 '08 #4
dazzler
75
wat if i want to receive the data from a particular client whose address is known???
i want to receive data from a particular client whose address is known...
wat other arguments should i add to tat system cal??
I think that you can't tell address who are you listening to, only the port what are you listening and that's enough

when you have received message then you can block it if it's come from wrong ip address
Mar 5 '08 #5
I think that you can't tell address who are you listening to, only the port what are you listening and that's enough

when you have received message then you can block it if it's come from wrong ip address

but tat recvfrom() system call does have tat sender's address option which means i can receive from a particular sender.....
Mar 6 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Premshree Pillai | last post by:
For the uninitiated: "Socket Programming in Python" at evolt.org: http://evolt.org/article/Socket_Programming_in_Python/17/60276/index.html ===== -Premshree http://www.qiksearch.com/] ...
8
by: gs | last post by:
Hi! This is my first time posting to a newsgroup so please be gentle to me :) Introduction to my problem: I'm studying at the university and a lot of friends and I use MSN to communicate....
2
by: | last post by:
I'm sort of new to both Python and socket programming so I appologize ahead of time if this is a dumb question. I have found that the following code works on windows but on linux I get an exception....
6
by: Maxim Veksler | last post by:
Hello, I wish to do some low level network stuff using python. I've googled somewhat and came up with pylibpcap, trouble is I can't compile it on my Ubuntu 6.10 workstation. Can someone please...
6
by: =?utf-8?q?O=C4=9Fuz_Yar=C4=B1mtepe?= | last post by:
Is it possible to send a data object like a tuple or a list in socket programming? If so how? It seems with socket module it is only possible to send strings. -- Oğuz Yarımtepe...
1
by: inhahe | last post by:
i'm trying to make a .dll that will let me use WSAPoll, which is a windows sockets function, to mimic select.poll on a windows box. i cbb learning python extensions, so i'm just going to use...
2
by: srinivasan srinivas | last post by:
Hi, I am going to do some socket related programming in Python. Before that, I wish to know the Gotchas of Python Scoket Programming. Can anyone send me any link that satisfies my needs?? Thanks,...
1
by: =?iso-8859-1?q?C=E9dric_Lucantis?= | last post by:
Hi, Le Friday 13 June 2008 18:29:06 srinivasan srinivas, vous avez écrit : Yes, the friendly manual :) http://docs.python.org/lib/module-socket.html and if you want to know more about...
5
by: fishfin | last post by:
I was working through a tutorial about how to write a server using python (the url is bellow). I am sure that the server is working to some degree because when the server is running localhost:8080...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.