473,734 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

socket question

Hi,

I am following a few tutorial and this howto:
*************** *************** *************** *************** *
............
What happens in the web server is a bit more complex. First, the web
server creates a "server socket".

#create an INET, STREAMing socket
serversocket = socket.socket(
socket.AF_INET, socket.SOCK_STR EAM)
#bind the socket to a public host,
# and a well-known port
serversocket.bi nd((socket.geth ostname(), 80))
#become a server socket
serversocket.li sten(5)

A couple things to notice: we used socket.gethostn ame() so that the
socket would be visible to the outside world. If we had used s.bind(('',
80)) or s.bind(('localh ost', 80)) or s.bind(('127.0. 0.1', 80)) we would
still have a "server" socket, but one that was only visible within the
same machine.
............
*************** *************** *************** *************** *

My problem is that I cannot connect to my server if the client is not on
the same PC (although I'm doing the above).
Also:
1) my server has more than one IP addresses
2) my server does not have any DNS name
.... so I want to connect to an IP address that I can ping but has no
name.
How can I do that ?

Regards,

Philippe






--
*************** ************
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
*************** ************

Jul 18 '05 #1
6 1825
> A couple things to notice: we used socket.gethostn ame() so that the
socket would be visible to the outside world. If we had used s.bind(('',
80)) or s.bind(('localh ost', 80)) or s.bind(('127.0. 0.1', 80)) we would
still have a "server" socket, but one that was only visible within the
same machine.
This is wrong. There is a difference between passing '' and 'localhost'. The
latter binds the socket only to the ip 127.0.0.1, where '' binds it to all
available ips.
My problem is that I cannot connect to my server if the client is not on
the same PC (although I'm doing the above).
Also:
1) my server has more than one IP addresses
2) my server does not have any DNS name
... so I want to connect to an IP address that I can ping but has no
name.
How can I do that ?


Pass the ip as hostname (as string like "192.168.1. 10")

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
Thanks you! that did it.

PS: the 'wrong' info I got seems to be in the official howtos
http://www.amk.ca/python/howto/sockets/

Regards,

Philippe

On Mon, 07 Feb 2005 18:23:28 +0100, Diez B. Roggisch wrote:
A couple things to notice: we used socket.gethostn ame() so that the
socket would be visible to the outside world. If we had used s.bind(('',
80)) or s.bind(('localh ost', 80)) or s.bind(('127.0. 0.1', 80)) we would
still have a "server" socket, but one that was only visible within the
same machine.


This is wrong. There is a difference between passing '' and 'localhost'. The
latter binds the socket only to the ip 127.0.0.1, where '' binds it to all
available ips.
My problem is that I cannot connect to my server if the client is not on
the same PC (although I'm doing the above).
Also:
1) my server has more than one IP addresses
2) my server does not have any DNS name
... so I want to connect to an IP address that I can ping but has no
name.
How can I do that ?


Pass the ip as hostname (as string like "192.168.1. 10")


Jul 18 '05 #3

Philippe C. Martin wrote:
My problem is that I cannot connect to my server if the client is not on the same PC (although I'm doing the above).

Does the machine running the server code also have a firewall installed
that blocks access to the server port from outside? That is the only
possibility I can think of that prevents a non-local client from
connecting.

Also, please do a netstat -a on the machine running the server and see
the IP addresses to which the listening port is bound.

Thanks,
-Kartic

Jul 18 '05 #4
Philippe C. Martin wrote:
Thanks you! that did it.


That makes me wonder what socket.gethostn ame() was returning.
It wasn't 'localhost', was it?

Steve
Jul 18 '05 #5
Yes it was.

Regards,

Philippe

On Mon, 07 Feb 2005 21:30:28 +0000, Steve Horsley wrote:
Philippe C. Martin wrote:
Thanks you! that did it.


That makes me wonder what socket.gethostn ame() was returning.
It wasn't 'localhost', was it?

Steve


Jul 18 '05 #6
Thanks, it was a bind problem: socket.gethostn ame() returns 'localhost'
where '' is was was needed.

Regards,

Philippe

On Mon, 07 Feb 2005 11:02:13 -0800, Kartic wrote:

Philippe C. Martin wrote:
>> My problem is that I cannot connect to my server if the client is not on >> the same PC (although I'm doing the above).

Does the machine running the server code also have a firewall installed
that blocks access to the server port from outside? That is the only
possibility I can think of that prevents a non-local client from
connecting.

Also, please do a netstat -a on the machine running the server and see
the IP addresses to which the listening port is bound.

Thanks,
-Kartic


Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3279
by: Gonçalo Rodrigues | last post by:
Hi, My setup is the following: I have socket s from which I want to read and write. So I made the following set up: There is a thread whose only job is to read. Any data read (from recv call) is just passed to (some) Queue. This thread is "owned" by a second thread waiting on a Queue for write requests. The thread just pops these from the Queue, and calls the send method from the socket. This thread also takes care of closing the...
1
3396
by: John Sheppard | last post by:
Thanks to everyone that responded to my previous Socket Programming question. Now I have run into some behavior that I don't quite understand. Programming environment. VS.NET 2003, C#, Windows XP. About the architecture: I have a socket server dll that contains a class that handles connections for a given local ipaddress and port. This class(server) can be started or stopped by calls to the appropriate functions. The server class has...
2
15328
by: djc | last post by:
I read a network programming book (based on framework 1.1) which indicated that you should 'never' use the RecieveTimeout or the SendTimeout 'socket options' on TCP sockets or you may loose data. I now see the socket.RecieveTimeout 'property' in the visual studio 2005 help documentation (framework 2.0) and it has example of it being used with TCP socket. This propery is also listed as 'new in .net 2.0'. 1) is the socket.RecieveTimeout...
0
4684
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a number of different types of data coming in. I have a databuffer for each type of data coming in.
6
6446
by: roblugt | last post by:
I have what I imagine is a well-known .Net networking problem, but even though I've Googled for some time I've not yet come across a thread where this has been fully explained... There is a fairly common idiom (at least in the Java/UNIX/Win32 worlds) where a socket connection is established and the program then utilises two threads: one dedicated to reading from the socket and the other one concurrently writing to the socket - both using...
4
3604
by: Engineerik | last post by:
I am trying to create a socket server which will listen for connections from multiple clients and call subroutines in a Fortran DLL and pass the results back to the client. The asynchronous socket client and asynchronous socket server example code provided in the .NET framework developers guide is a great start but I have not dealt with sockets before and I am struggling with something. From what I can tell the sample server code ...
6
2849
by: Sean | last post by:
Hi Everyone, My apologies for a somewhat dump question but I am really stuck. I have been working on this code for two days straight I am dont know what is wrong with it. when I run the code, All I get is Input: and the program quits. I also tried reading this online but I didn't quite get it. What is the diff between sin_addr and sin_addr.s_addr. My understanding is that the latter is the IP address of my machine where as the former is...
6
15606
by: billiejoex | last post by:
Hi there. I'm setting up test suite for a project of mine. situations, if the socket is closed on the other end or not. I noticed that I can "detect" such state if a call to socket.read() returns 0 but it seems a little poor to me. :-\ Is there a reliable way to test such socket 'state'?
1
1829
by: =?Utf-8?B?UmFqbmk=?= | last post by:
Dear Sir/Mam, I have written a server code using the Windows Socket API's. Wherein I have created the socket and bound it to a particular IP address and port number. Later I have made the socket in non-blocking mode by using the proper socket option ( i.e. SO_RCVTIMEO). After which with the use of recv() I am trying to get into the receive mode. Here as the receive time out is being used the socket should come out of the block mode after...
2
2092
by: Ali Hamad | last post by:
Hello All : A socket question from a networking newbie. I need to create a server that: 1) receive a message from client. 2) check that message and response to it. 3) the client get the server message and send another message. 4) finally, the server receive the message and close the connection.
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.