Re: [Tutor] sockets and networking

2013-02-12 Thread Alan Gauld
On 12/02/13 04:27, richard kappler wrote: ports to a python program on the laptop. Someone suggest using sockets, with which I am completely unfamiliar. I've read the socket docs and admit I find them quite confusing. Can someone point me to a/some good beginner tutorials on sockets/networking f

Re: [Tutor] sockets and networking

2013-02-11 Thread eryksun
On Mon, Feb 11, 2013 at 11:27 PM, richard kappler wrote: > I've read the socket docs and admit I find them quite confusing. Can someone > point me to a/some good beginner tutorials on sockets/networking for me to > look at? Try Doug Hellmann's Python Module of the Week: http://www.doughellmann.c

[Tutor] sockets and networking

2013-02-11 Thread richard kappler
I want to be able to communicate between a raspberry pi and a laptop running ubuntu, transferring text from the pi to the laptop. Specifically the Pi would be running poscketsphinx speech rec and would send the generated text through the crossover between the two ethernet ports to a python program

Re: [Tutor] sockets, servers, clients, broadcasts...?

2010-06-04 Thread ALAN GAULD
> Look at the example in my tutorial. It doesn't use threads but What is the link for the tutorial? In my sig. Go to the V2 version and look for the Network Programming topic. > what is a context? I dealt with them a lot in Android programming Nothing to do with Android contexts I'm simply u

Re: [Tutor] sockets, servers, clients, broadcasts...?

2010-06-04 Thread Alex Hall
On 6/4/10, Alan Gauld wrote: > > "Alex Hall" wrote > >> connect to you as a client. It appears, though, that I need a loop >> to >> have a server make any sense at all, to handle incoming data and >> connection requests. > > You need to listen then process incoming messages then listen some > mor

Re: [Tutor] sockets, servers, clients, broadcasts...?

2010-06-04 Thread Alan Gauld
"Alex Hall" wrote connect to you as a client. It appears, though, that I need a loop to have a server make any sense at all, to handle incoming data and connection requests. You need to listen then process incoming messages then listen some more, so yes you will need a loop. Probaqbly an i

Re: [Tutor] sockets, servers, clients, broadcasts...?

2010-06-04 Thread Alex Hall
Thanks for the suggestions, everyone. For now, more as a way to introduce myself to all this, I am going to have my program automatically start a server and pop up that server's ip. Then, if you want, you can type in an ip and connect to the server at that ip (ports are hard-coded at ). That wa

Re: [Tutor] sockets, servers, clients, broadcasts...?

2010-06-04 Thread spir
On Thu, 3 Jun 2010 18:03:34 -0400 Alex Hall wrote: > Hi all, > I am a CS major, so I have had the required networking class. I get > the principles of networking, sockets, and packets, but I have never > had to actually implement any such principles in any program. Now I > have this Battleship ga

Re: [Tutor] sockets, servers, clients, broadcasts...?

2010-06-03 Thread Alan Gauld
"Alex Hall" wrote *somehow, your instance of the program starts up a server that broadcasts something; your enemy has selected "client", and is now (SOMEHOW) listening for the signal your server is broadcasting *the signal is picked up, and, SOMEHOW, you and your opponent connect and can sta

[Tutor] sockets, servers, clients, broadcasts...?

2010-06-03 Thread Alex Hall
Hi all, I am a CS major, so I have had the required networking class. I get the principles of networking, sockets, and packets, but I have never had to actually implement any such principles in any program. Now I have this Battleship game (not a school assignment, just a summer project) that I am t

Re: [Tutor] sockets

2007-06-18 Thread Alan Gauld
"Linus Nordström" <[EMAIL PROTECTED]> wrote > im having problem whit recv. It will not break the loop if ther are > nothing more to recive. Take a look at the client side of the address book example in my network profgramming topic. It shows an example of breaking out of a recv loop. Another opt

Re: [Tutor] sockets

2007-06-18 Thread Linus Nordström
gusse i use this thread as my own little help thread.. :) im having problem whit recv. It will not break the loop if ther are nothing more to recive. It dose recv all tit should, but then it go another round in the loop and get stuck on recv, as far as print debugging has showed, Dont realy know

Re: [Tutor] sockets

2007-06-17 Thread Linus Nordström
Oh, thank you, exactly what i was looking for :) On 6/18/07, Andreas Kostyrka <[EMAIL PROTECTED]> wrote: > Tip: consult the documentation of the struct module. > > Andreas > > -- Ursprüngl. Mitteil. -- > Betreff:[Tutor] sockets > Von:"Linus Nordst

Re: [Tutor] sockets

2007-06-17 Thread Andreas Kostyrka
Tip: consult the documentation of the struct module. Andreas -- Ursprüngl. Mitteil. -- Betreff:[Tutor] sockets Von:"Linus Nordström" <[EMAIL PROTECTED]> Datum: 17.06.2007 22:47 Hello I'm trying to rewrite a chat-program i did in school this spring

[Tutor] sockets

2007-06-17 Thread Linus Nordström
Hello I'm trying to rewrite a chat-program i did in school this spring in python, the school program was in java. All this to leran python. Anyway. I m trying to send a message using udp to a server that conntains the message 3 0 0 0, it has to be in network byte order and unsigned. I have tried t

Re: [Tutor] sockets

2006-05-04 Thread János Juhász
server = SocketServer.TCPServer( ('', 79), FingerHandler) server.serve_forever() Matt wrote --- Date: Thu, 04 May 2006 09:23:38 -0700 From: Matt Richardson <[EMAIL PROTECTED]> Subject: Re: [Tutor] sockets To: Tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: tex

Re: [Tutor] sockets

2006-05-04 Thread Hugo González Monteverde
Matt Richardson wrote: > I need to send some data, 2 strings and a list, to a remote computer. > After thinking about it some last night, it wouldn't be hard to just > send it all as a string and then parse it on the receiving end. Well if the excercise itself is not parsing a string, you can ju

Re: [Tutor] sockets

2006-05-04 Thread Matt Richardson
Kent Johnson wrote: > > This would be very easy to do with XML-RPC. On the server side, writ a > function that takes three parameters - the IP address, MAC address, and > traceroute dump - and saves them to a database. Use SimpleXMLRPCServer > to expose the function. On the client side, gather

Re: [Tutor] sockets

2006-05-04 Thread Kent Johnson
Matt Richardson wrote: > I need to send some data, 2 strings and a list, to a remote computer. > After thinking about it some last night, it wouldn't be hard to just > send it all as a string and then parse it on the receiving end. > > I'm writing a program for work (and for a class project, so

Re: [Tutor] sockets

2006-05-04 Thread Matt Richardson
I need to send some data, 2 strings and a list, to a remote computer. After thinking about it some last night, it wouldn't be hard to just send it all as a string and then parse it on the receiving end. I'm writing a program for work (and for a class project, so no answers!) that will provide s

Re: [Tutor] sockets

2006-05-03 Thread Kent Johnson
Matt Richardson wrote: > Just verifying what I looked up earlier: are strings and binary > (through struct.pack) the only data types that can be sent through a > socket? This is my first crack at socket programming, so I'll probably > have lots of questions to bug you with. The socket library

[Tutor] sockets

2006-05-03 Thread Matt Richardson
Just verifying what I looked up earlier: are strings and binary (through struct.pack) the only data types that can be sent through a socket? This is my first crack at socket programming, so I'll probably have lots of questions to bug you with. thanks, Matt __

Re: [Tutor] sockets, files, threads

2005-01-20 Thread Marilyn Davis
Danny! I couldn't resist trying threading again, now that the mysterious single-threading behavior is gone. I didn't put any locks anywhere. And it runs like a champ. Like a super champ. Either I had to put back threading or I had to make a family of socket-readers, or lose some functionality

Re: [Tutor] sockets, files, threads

2005-01-19 Thread Marilyn Davis
On Wed, 19 Jan 2005, Danny Yoo wrote: > On Wed, 19 Jan 2005, Marilyn Davis wrote: > > > class Exim: > > def __init__(self): > > self.fdin = None > > self.err_flush = [] > > self.stdout, self.stdin, self.stderr = popen2.popen3('%s -t' % > > MAILER) > > se

Re: [Tutor] sockets, files, threads

2005-01-19 Thread Danny Yoo
On Wed, 19 Jan 2005, Marilyn Davis wrote: > class Exim: > def __init__(self): > self.fdin = None > self.err_flush = [] > self.stdout, self.stdin, self.stderr = popen2.popen3('%s -t' % > MAILER) > self.fdin = self.stdin.fileno() > self.fdout = s

Re: [Tutor] sockets, files, threads

2005-01-19 Thread Marilyn Davis
Thank you Kent. On Wed, 19 Jan 2005, Kent Johnson wrote: > Marilyn Davis wrote: > >>few lines up, right where 'client_socket' is initialized. Like this: > >> > >>### > >>try: > >>client_socket, client_addr = self.server_socket.accept() > >>Spawn(client

Re: [Tutor] sockets, files, threads

2005-01-19 Thread Marilyn Davis
> > > What about when I do an explicit call to a close inside a __del__. Is > > that a bad idea? > > I usually prefer to add a close() method to my objects that releases > resources, rather than __del__(), because it's more visible. > OK Danny! I found it! When I was almost asleep last night

Re: [Tutor] sockets, files, threads

2005-01-19 Thread Kent Johnson
Marilyn Davis wrote: few lines up, right where 'client_socket' is initialized. Like this: ### try: client_socket, client_addr = self.server_socket.accept() Spawn(client_socket).start() except socket.error, msg: time.sleep(.5)

Re: [Tutor] sockets, files, threads

2005-01-18 Thread Danny Yoo
On Tue, 18 Jan 2005, Marilyn Davis wrote: > while 1: > if log.level & log.calls: > log.it("fd%d:py_daemon.py: Waiting ...", self.descriptor) > try: > client_socket, client_addr = self.server_socket.accept() > except (EOF

Re: [Tutor] sockets, files, threads

2005-01-18 Thread Marilyn Davis
Thank you so much Danny. I know how hard it is to look at and comment on other people's code. You know I teach C and Python and I have to say, though, that reading students' Python is 100 times easier than reading their C. And, I hope you're feeling better. I hate to think of you struggling thr

Re: [Tutor] sockets, files, threads

2005-01-18 Thread Danny Yoo
On Tue, 18 Jan 2005, Danny Yoo wrote: > In fact, as far as I can tell, none of the Spawn() threads are > communicating with each other. As long as your threads are working > independently of each other --- and as long as they are not writing to > global variables --- you do not need locks. > >

Re: [Tutor] sockets, files, threads

2005-01-18 Thread Danny Yoo
Hi Marilyn, [Long program comments ahead. Please forgive me if some of the comments are overbearing; I'm trying to get over a cold, and I'm very grumpy. *grin*] Some comments on the code follow. I'll be focusing on: > http://www.maildance.com/python/doorman/py_daemon.py One of the import

Re: [Tutor] sockets, files, threads

2005-01-16 Thread Marilyn Davis
On Sat, 15 Jan 2005, Danny Yoo wrote: > > > > I have only wrapped my lock around file-descriptor creations. Should I > > wrap it around closings too? Or the whole open -> close transaction? > > It sounds like error-prone work to do the latter. What am I missing? > > Hi Marilyn, > > Can you

Re: [Tutor] sockets, files, threads

2005-01-15 Thread Danny Yoo
> I have only wrapped my lock around file-descriptor creations. Should I > wrap it around closings too? Or the whole open -> close transaction? > It sounds like error-prone work to do the latter. What am I missing? Hi Marilyn, Can you send a link to the source code to the Tutor list? I'm ge

Re: [Tutor] sockets, files, threads

2005-01-15 Thread Marilyn Davis
p.p.s. I have only wrapped my lock around file-descriptor creations. Should I wrap it around closings too? Or the whole open -> close transaction? It sounds like error-prone work to do the latter. What am I missing? What should I be reading to get a better clue? I'll do some googling. Thank

Re: [Tutor] sockets, files, threads

2005-01-15 Thread Marilyn Davis
Dearest Tutors, Bah! It's not over yet. I don't know why, but again my file descriptors are being trampled upon now and then. This time I can see in my log that I'm not trampling on them myself, like I used to do, unless I'm making calls to the system that I'm not aware of. And, first I get th

Re: [Tutor] sockets, files, threads

2005-01-15 Thread Marilyn Davis
Whew! What a trip this bug has been! Danny was exactly right here: > is exactly the sort of thing I'd expect if two threads were > contending for the same resource, so let's see if the bug has to do > with this. This bug drove me nuts. (it's a short drive) So I started wrapping my file open

Re: [Tutor] sockets, files, threads

2005-01-13 Thread Alan Gauld
> Where did my 'ooo' go? > > #! /usr/bin/env python > import os > > fobj = open('/tmp/xxx','w') > fobj.write('ooo\n') fobj.flush() File objects use buffered IO and by changing from using file objects to file descriptors half way through the buffer could be in any state. You need to flush() to

Re: [Tutor] sockets, files, threads

2005-01-12 Thread Danny Yoo
On Wed, 12 Jan 2005, Marilyn Davis wrote: > I was looking at my use of file objects and file descriptors and I wrote > this sample program and was very surprised by the result -- which makes > me think there's something here that I don't understand. Where did my > 'ooo' go? > > #! /usr/bin/env p

Re: [Tutor] sockets, files, threads

2005-01-12 Thread Marilyn Davis
On Wed, 12 Jan 2005, Danny Yoo wrote: Thank you so much for thinking about this Danny. > > When stuff was read from the exim socket, it was stored in a tempfile, > > so that I could release the exim process, then I lseek to the front of > > the tempfile and have it handy. I see from all my debu

Re: [Tutor] sockets, files, threads

2005-01-12 Thread Danny Yoo
> Just double checking something: are you dealing with threads? Hi Marilyn, Argh, that was a dumb question. Pretend I didn't ask it that way. *grin* I meant to ask: How do you deal with threads? Is the temporary file a global resource that the threads all touch? If so, have you done any sy

Re: [Tutor] sockets, files, threads

2005-01-12 Thread Danny Yoo
On Wed, 12 Jan 2005, Marilyn Davis wrote: > When stuff was read from the exim socket, it was stored in a tempfile, > so that I could release the exim process, then I lseek to the front of > the tempfile and have it handy. I see from all my debugging and logging > that the file descriptor for th

[Tutor] sockets, files, threads

2005-01-12 Thread Marilyn Davis
Hello Tutors, I've been banging my head against this bug for 4 days. I can't think of how to ask for help except to give a birds eye view of the situation. I have a python daemon that is listening on a UNIX socket for communication with exim, my Mail Transfer Agent. Each mail message has its ow