Re: server side socket program hangs

From: Jørgen Cederberg (jorgencederberg_at_hotmail.com)
Date: 10/17/03


Date: Fri, 17 Oct 2003 09:19:37 +0200

anuradha.k.r@sify.com wrote:
> hi,
> my initial program was to take host value as ''(INADDR_ANY)
> only.during my trial and error only i started using
> gethostname.however as of now i am running my client (C program) also
> from the same machine only.so it should not make any difference.
> I've reverted bac to host ''.my program still hangs.i 'v e tried
> changing the port address,but doesn't work.pls help
> thanx,
> AKR.

Hi

this is pretty odd. As mentioned in the previous mail, the program works
with my client program (written in Python by the way).

You keep saying that the programs 'hang', what do mean by that? I've
tried the program and all I can say is that it works. Are you sure that
your client works correctly?

Regards
Jorgen

>
>
> Jørgen Cederberg <jorgencederberg@hotmail.com> wrote in message news:<9sujb.997$Z54.969@news.get2net.dk>...
>> anuradha.k.r@sify.com wrote:
>> > hi,
>> > i guess no one is ready to help.neways,my problem is getting
>> > solved.I 've slightly modified program (one of the samples found in
>> > the net),now program creates socket,gives bind ,listen success.however
>> > when i debug at accept it goes to the socket.py,at the accept()
>> > function definition.and one more step ahead and it hangs.i dono how to
>> > debug here(inside socket.py).
>> >
>> > here is how the code looks like
>>
>> Hi ...
>>
>> the program actually works - but there is a quirk, look below for details.
>>
>> >
>> > ////////////////
>> > from socket import *
>> > import sys
>> >
>> > try:
>> > s= socket(AF_INET,SOCK_STREAM)
>> > print 'socket created'
>> > except error:
>> > print 'socket not created'
>> > host = ''
>> > port = 9323
>> > try:
>> > s.bind((gethostname(),port))
>>
>> You are binding the socket to the hostname of your computer, instead of
>> ''. Thus it will only accept connections specific to the hostname and
>> therefor fail if you try to connect to localhost or 127.0.0.1
>>
>>
>> > print 'bind success'
>> > except error:
>> > print 'bind'
>> > try:
>> > s.listen(1)
>> > print 'listen success'
>> > except error:
>> > print 'listen'
>> >
>> > conn,addr = s.accept()
>> > print 'client is at ', addr
>> > data = conn.recv(1024)
>> > conn.send(data)
>> > conn.close()
>> > ////////////////////////
>> > but i have a feeling that teher's some problem with the port or
>> > some problem in the program that it hangs.can anyone help?or atleast
>> > give me few links where i can find a solution,thanx.
>> > AKR.
>>
>>
>> Hope this helps
>> Jorgen



Relevant Pages

  • Re: how to get remote host name
    ... it means the IP address you provided has no associated host name ... if the remote connection gave you the ability to query its name via the ... I had used gethostbyaddrto retreive the hostname of the other side. ... If the server and the client in the same subnetwork everything work ...
    (microsoft.public.vc.mfc)
  • Re: Changing hostname
    ... ipcheck - Dyndns.org client to register your dynamic IP address ... Some of those can already update you hostname proper and your ipaddr ... if you have a firewall machine with 2+ NICS in it. ... what ever you call it is the public facing and dynamic interface ...
    (Debian-User)
  • Re: Socket - gaierror
    ... I suspect that the name of your client ... UNIX/Linux you can use the hostname command; ... e-mail via SMTP could need the local host name for at least two ... to resolve the odd-ball name that your system provides. ...
    (comp.lang.python)
  • Re: servergespeicherte Profile
    ... >> NT4.0 Client: ... >> Ein Ping auf den eigenen Hostname funzt. ... Egal ob IP oder Hostname. ... Da hilft DNS nix. ...
    (microsoft.public.de.german.windows.server.active_directory)
  • Re: problem with nfs mount and "1831-008" error -> "vmount: A system call received..."
    ... hostname resolution ip address to hostname and ip address ... host hostname from both sides (Server and Client) ... but the network should be ok between the NIM server and the ...
    (comp.unix.aix)