UGN Security Forums
My ProfileMember DirectoryLogin
Search our ForumsView our FAQView our Site Rules
View our CalendarView our Active TopicsGo to our Main Page

UGN Security Store
 

Network Sites UGN Security, The GoNix Initiative, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
September
Su M Tu W Th F Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Sponsored Links
Latest Postings
The History Thread...
by Gremelin
Today at 09:42 AM
Doom 3
by Cyrez
09/11/14 08:58 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666
08/22/14 09:21 AM
Latest Reviews
Topic Options
Rate This Topic
#17668 - 09/04/02 08:47 AM Winsock Control - Advanced uses
SilentRage Offline
DollarDNS Owner

Registered: 03/04/02
Posts: 1273
Loc: OH, USA
This is a fairly simple notice for people already familiar with the uses of the Winsock control.

Trick #1 - The BIND Method

For some reason, it wasn't until recently that I discovered exactly what the Bind method can do. Previously I thought it was only good for binding UDP sockets to a port.

I was wrong. This is the answer to my prayers. Various programs give you the option of listening on any local IP. 0.0.0.0 is for ANY port of course. Or you may select 127.0.0.1 if you only want to accept local connections. And of course, if you have more than one IP, you can listen on any of them as well.

While this is fairly obvious in the Winsock API, until now, I thought it was outside the Winsock Control's capabilities.

Want to create a TCP listening session on 127.0.0.1? Do the following:

Winsock.Bind 10000, "127.0.0.1"
Winsock.Listen

Trick #2 - UDP Broadcast

This one isn't as obvious as the other one, but just as easy. First, let me paint an example of its use.

Problem: You have a multiplayer network-enabled game, and you want to have the convenience of the game giving you a listing of all available hosted games on the network.

Solution: UDP Broadcasting! Set each host to bind a UDP socket to a single port - let's say 4500.

Host.Bind 4500, "0.0.0.0"

Ok, now the Client has to somehow get that hosts address. Do this:

Client.RemoteHost = "255.255.255.255"
Client.RemotePort = 4500
Client.SendData "PING"

That well send "PING" to every computer on the network targeted at port 4500! Now, the host is expecting a request like this, so it sends a response:

Host.RemoteHost = Host.RemoteHostIP
Host.SendData "PONG"

Now the client will recieve a PONG from every host on the network - and it may list each host for the user to connect to via TCP after whatever means of negotiation you want.

-

If you don't know how to use the Winsock Control, and would like to know, ask me to send you an example of it's use.
_________________________
Domain Registration, Hosting, Management
http://www.dollardns.net

Top
Sponsored Links
      
#17669 - 09/04/02 08:37 PM Re: Winsock Control - Advanced uses
ninjaneo Offline
UGN Security Staff

Registered: 03/06/02
Posts: 256
Loc: CA, USA
now thats just fucking jeet

Top
#17670 - 09/05/02 04:01 PM Re: Winsock Control - Advanced uses
Mornse Offline
Member

Registered: 03/03/02
Posts: 185
Loc: Vancouver
I don't really understand the Bind. Like what would you use that for?
_________________________
Cha want some w***up?

http://www.dopeskill.com

Top
#17671 - 09/05/02 06:12 PM Re: Winsock Control - Advanced uses
SilentRage Offline
DollarDNS Owner

Registered: 03/04/02
Posts: 1273
Loc: OH, USA
Well, I was pretty clear on what it can be used for. So, I'll explain a bit about what it means to have more than one IP and the 'special' IP's.

Let's say your computer has a network card on a local network. This network card may have the IP of 192.168.1.3 for example. However, your LAN doesn't have access to the internet, so you have to use a 56k dial-up connection. When you get on the internet, you now also have an internet IP given to you by your ISP. Let's say it is 12.345.6.78. These IP addresses give your applications special capabilities when they listen on a port. You see, when somebody tries to connect to your computer, not only is there a PORT it's connecting to, it's also connecting to an IP. Here, I'll explain.

You have a FTP server listening on 192.168.1.3:21. In order for a client to connect to it, the destination IP address must be 192.168.1.3. That is an IP only accessible from your network. That means ONLY people on your LAN can connect to the FTP server. If somebody tried to connect to 12.345.6.78:21 - it will be a connection refused cause there's nothing listening on that IP.

The opposite is true. Servers listening on 12.345.6.78 cannot be connected to from other computers on the LAN (unless you have some static routing going on - but that's special). However, it can easily be connected to by people on the internet.

Now, there is also a special IP 127.0.0.1. If a server is listening on that IP, only programs on the same computer can connect to it. If some other computer tried connecting to 127.0.0.1... well, it won't be your computer it's trying to connect to. Understand? That means you can have servers on certain IP's to restrict who can connect to it.

Another special IP is 0.0.0.0. This is where a server is listening on ALL IP addresses. It doesn't matter if you're connecting to 127.0.0.1, 12.345.6.78, or 192.168.1.3 - they'll all successfully connect.

The BIND method is how you can tell the winsock control on WHICH IP you want to listen on. If you don't tell it what IP you want it to listen on, it will always listen on 0.0.0.0 - and you may not want that.

Now go ahead and read what I said about the BIND method above and you will better understand what I'm talking about.
_________________________
Domain Registration, Hosting, Management
http://www.dollardns.net

Top
#17672 - 09/05/02 08:17 PM Re: Winsock Control - Advanced uses
Mornse Offline
Member

Registered: 03/03/02
Posts: 185
Loc: Vancouver
Ahh, gotcha. Thank you very much for the explanation. That's cool shit, I'm gonna try that one time.
_________________________
Cha want some w***up?

http://www.dopeskill.com

Top
#17673 - 09/26/02 07:49 AM Re: Winsock Control - Advanced uses
psychogen Offline
Member

Registered: 03/02/02
Posts: 257
Loc: UK
/me smiles

Nice article SilentRage

I have been using bind for the OfficeChat app I am writing part time. You may remember when I asked about DHCP detection through VB, well I after I did some reading online I found out that I was going totally the complex way of getting around to finding the OfficeChat server on a LAN, so I used bind to broadcast available servers from a central broadcasting server (with static ip) then the client can choose which server to connect to from a listview.

:p

Bind rox0rs!!!
_________________________
The use of "hacker" to mean "security breaker" is a confusion on the part of the mass media. We hackers refuse to recognize that meaning, and continue using the word to mean, "Someone who loves to program and enjoys being clever about it."
--------------------
"Its not a bug, its a feature" (Epic Games)

Top

Featured Member
Registered: 03/02/02
Posts: 136
Forum Stats
2148 Members
46 Forums
34464 Topics
69634 Posts

Max Online: 1567 @ 04/25/10 02:20 AM
Top Posters
UGN Security 27626
Gremelin 7193
§intå× 3255
SilentRage 1273
Ice 1146
pergesu 1136
Infinite 1041
jonconley 955
Girlie 908
unreal 860
Newest Members
Tim050, Gecko666, defghi795767, Devo60, ali
2148 Registered Users
Who's Online
1 registered (Gremelin), 324 Guests and 375 Spiders online.
Key: Admin, Global Mod, Mod
Latest News


Donate
  Get Firefox!
Get FireFox!