Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76854

Re: socket issue with recv()

From Marko Rauhamaa <marko@pacujo.net>
Newsgroups comp.lang.python
Subject Re: socket issue with recv()
Date 2014-08-23 11:46 +0300
Organization A noiseless patient Spider
Message-ID <87oavb8ufc.fsf@elektro.pacujo.net> (permalink)
References <64392c10-28c5-4eee-93d2-7dd4edba56fe@googlegroups.com>

Show all headers | View raw


Arthur Clarck <aclarck5@gmail.com>:

> What is happening is that I got some datas from the remote site,
> Something like 'Contacting BH: ...'
> But directly followed by 'remote site is closed.

This works:

========================================================================
#!/usr/bin/env python3

import sys, socket, os

def main():
    s = socket.socket()
    s.connect(("mail.python.org", 25))
    if os.fork() > 0:
        s.close()
        os.wait()
        os._exit(0)
    while True:
        data = s.recv(50)
        sys.stderr.write("{}\n".format(repr(data)))
        if not data:
            break

if __name__ == "__main__":
    main()
========================================================================


Marko

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

socket issue with recv() Arthur Clarck <aclarck5@gmail.com> - 2014-08-23 01:23 -0700
  Re: socket issue with recv() Arthur Clarck <aclarck5@gmail.com> - 2014-08-23 01:39 -0700
  Re: socket issue with recv() Marko Rauhamaa <marko@pacujo.net> - 2014-08-23 11:46 +0300
  Re: socket issue with recv() dieter <dieter@handshake.de> - 2014-08-24 07:59 +0200

csiph-web