Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Mar 2002
Posts: 1,273
DollarDNS Owner
OP Offline
DollarDNS Owner
Joined: Mar 2002
Posts: 1,273
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
Joined: Mar 2002
Posts: 256
Likes: 1
UGN Security Staff
Offline
UGN Security Staff
Joined: Mar 2002
Posts: 256
Likes: 1
now thats just [censored] jeet

Joined: Mar 2002
Posts: 185
M
Member
Offline
Member
M
Joined: Mar 2002
Posts: 185
I don't really understand the Bind. Like what would you use that for?


Cha want some w***up?

http://www.dopeskill.com
Joined: Mar 2002
Posts: 1,273
DollarDNS Owner
OP Offline
DollarDNS Owner
Joined: Mar 2002
Posts: 1,273
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
Joined: Mar 2002
Posts: 185
M
Member
Offline
Member
M
Joined: Mar 2002
Posts: 185
Ahh, gotcha. Thank you very much for the explanation. That's cool [censored], I'm gonna try that one time.


Cha want some w***up?

http://www.dopeskill.com
Joined: Mar 2002
Posts: 257
Member
Offline
Member
Joined: Mar 2002
Posts: 257
/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)

Link Copied to Clipboard
Member Spotlight
Phatal
Phatal
Houston, TX
Posts: 298
Joined: April 2004
Forum Statistics
Forums41
Topics33,840
Posts68,858
Average Daily Posts1
Members2,176
Most Online3,253
Jan 13th, 2020
Latest Postings
Where and how do you torrent?
by danni75 - 03/01/24 05:58 AM
Animation,
by JohanKaariainen - 08/15/19 01:18 AM
Blackbeard.....
by Gremelin - 10/03/18 07:02 PM
my old account still exists!
by Crime - 08/10/18 02:47 PM
Okay WTF?
by HenryMiring - 09/27/17 01:45 AM
The History Thread...
by Gremelin - 08/11/17 12:11 PM
My friend NEEDS your HELP!
by Lena01 - 07/21/17 12:06 AM
I'm having fun with this guy.
by gabithompson730 - 07/20/17 01:50 AM
I want to upgrade my phone
by gabithompson730 - 07/20/17 01:49 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
AIM scene 99-03
by lavos - 09/02/13 08:06 AM
Planetside 2
by Crime - 03/04/13 07:10 AM
Beta Testers Wanted
by Crime - 03/04/13 06:55 AM
Hello Everyone
by Gremelin - 02/12/12 06:01 PM
Tracfone ESN Generator
by Zanvin Green - 01/18/12 01:31 PM
Python 3 issue
by Testing - 12/17/11 09:28 PM
tracfone airtime
by Drache86 - 07/30/11 03:37 AM
Backdoors and the Infinite
by ZeroCoolStar - 07/10/11 03:52 AM
HackThisZIne #12 Releaseed!
by Pipat2 - 04/28/11 09:20 PM
gang wars? l33t-wars?
by Gremelin - 04/28/11 05:56 AM
Consolidate Forums
by diggin2deep - 04/21/11 10:02 AM
LAN Hacking Noob
by Gremelin - 03/12/11 12:42 AM
Top Posters
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Likes Received
Ghost 2
Cyrez 1
Girlie 1
unreal 1
Crime 1
Powered by UBB.threads™ PHP Forum Software 7.7.5