Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LANs and Sockets

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
Does anyone know how to detect or find out if a socket connection is on a LAN or not? I have created a program with the ClientSocket and ServerSocket components. The application is designed for use over a LAN, (network) but I've found that anybody can simply call the server from wherever, (basically, outside of the network) and go about their business quite freely. This is a very bad thing for my product. I need my server to be able to detect if the incoming client connection is on a LAN or the internet. I can probably do this by checking IPs or something, but I don't know. Does anybody else??

Thanks, Cyprus
[noevil]
 
See FAQ 101-100 . There is an example on "Manual" creating a Server Socket.

Upon succesfull connection there is an Array which contains the IP of the connecting host.
hnd
hasso55@yahoo.com

 
um... ok. I think you kind of missed the question. I know how to get the IP of an incoming client. My problem is that I need to know if the incoming client is on the same network I am. I'd hate for the administrator to have to go in and manually input all of the IP's to accept. that would be completely unreasonable. I can't do it that way.
maybe should I match the first three parts of the IP to the servers? or is there an easier way... Cyprus
[noevil]
 
Make an AND function with the incoming IP-ADRESS and the network mask. Make another AND with your IP-ADRESS and the network mask , if these values are the same, the incoming ip-packet comes from your local segment, if the values are different the ip-packet comes from outside a router.
It is the same principle that is used to determine if an ip-adress resides on your own segment (this is before the first router) or after the first router.
The network mask is found in the network properties of your networksettings. Wim Vanherp
Wim.Vanherp@belgacom.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top