PDA

Click to See Complete Forum and Search --> : Help finding IP address and username of users on a network


Skoberlink
Mar 27th, 2007, 05:53 PM
I am making a network messenger and would like to add a function that checks the network for the usernames, IP addresses, and port numbers of users on the network. Is there visual basic code to do that? I need the actual code rather than just a link to a program or something. (sorry if that's assumed).

Thanks in advance for your help!
-Skoberlink

DigiRev
Mar 27th, 2007, 06:08 PM
This class here: http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=61827&lngWId=1

Will list all computers on the network. From there you can ping for their IP, although you should just able to use the name to connect to them.

And then you can use Winsock.RemoteHostIP once connected.

I'm not sure about the username (assuming you mean their Windows username). There might be some APIs for that but I'm not sure.

If not then you might just have to have the messenger send their Windows username (using the GetUsername() API function) once connected.

Skoberlink
Mar 27th, 2007, 06:13 PM
Yeah I meant their log on name (for example on my school network everyone has a login consisting of their initials and three numbers) I'd like to be able to find that to help identify users so that you know who you're messaging. I'll give this a try and see if it will work for what I'm trying. The uername bit was just something to make identifying users eaier but it wasn't really necessary. If there are any ideas on that they would be great, though!

DigiRev
Mar 27th, 2007, 06:40 PM
Yeah I meant their log on name (for example on my school network everyone has a login consisting of their initials and three numbers) I'd like to be able to find that to help identify users so that you know who you're messaging. I'll give this a try and see if it will work for what I'm trying. The uername bit was just something to make identifying users eaier but it wasn't really necessary. If there are any ideas on that they would be great, though!

More info on how your messenger is gonna work would help.

You are using Winsock right? Are you also building a server program that all clients will connect to? How are messages going to be transferred from one client to another?

Either way it should be real simple, but it really depends on those questions above.

Skoberlink
Mar 27th, 2007, 06:54 PM
Well, I am using winsock but this is my very first program using winsock (except for very simple learning excercises) so I really don't know too much yet right now.

For now the messenger is made to deal with just two people in one window. In other words, to talk to two people, you would actually have two windows open. (maybe in another version I'll make it so that multiple people can talk in one window but this is enough for the project)

The server and client are both in this program. The messages are sent as string variables using the senddata winsock function.

Thanks for bearing with me.

DigiRev
Mar 27th, 2007, 08:44 PM
Well, I am using winsock but this is my very first program using winsock (except for very simple learning excercises) so I really don't know too much yet right now.

For now the messenger is made to deal with just two people in one window. In other words, to talk to two people, you would actually have two windows open. (maybe in another version I'll make it so that multiple people can talk in one window but this is enough for the project)

The server and client are both in this program. The messages are sent as string variables using the senddata winsock function.

Thanks for bearing with me.

Don't worry, once you get the hang of the Winsock control and have written a few client/server programs you will see how it all works and it will be a peice of cake.

For a 1-on-1 chat, building the server into the messenger might work (one person would act as a server, the other, the client).

But when you bring multiple users into it, then it's best to just have one computer act as the server, and all clients connect to that server.

The server will be responsible for receiving those messages, and relaying them to all other clients. That's basically how it would work in a situation where everyone is chatting to eachother (in a chat room).

ie:

Client1 sends message to server
Server receives message
Sends to Client1, 2, 3, etc...

If it's 1-on-1 chat then you don't need to worry about this. But if more than 2 people connect then that's when it's best to use a server.

If you need help feel free to attach your project and I'll help.

Edit: Also, I wrote this very simple Winsock tutorial awhile ago. If you already know all the properties/methods of the Control then you probably don't need to read it, but it might still help:

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=44179&lngWId=1

Skoberlink
Mar 27th, 2007, 10:25 PM
Yeah, I'll take a look at that too. Thanks a ton DigiRev. You helped a lot!

DigiRev
Mar 27th, 2007, 10:45 PM
Yeah, I'll take a look at that too. Thanks a ton DigiRev. You helped a lot!

No problem. I love programming Winsock stuff so I enjoy helping when I can.;) :cool:

If you ever need help with something feel free to post here or PM me.

zynder
Mar 28th, 2007, 11:19 PM
I love your work DigiRev. :)

Chris H
Apr 18th, 2007, 09:33 PM
WMI will return to you who the currently logged in user is. Assuming, of course, you have admin rights on the machine and remote WMI is enabled.

Al42
Apr 19th, 2007, 03:38 PM
So will Environ$("username"), without needing WMI.