-
Jul 19th, 2022, 11:32 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Some General Networking Questions
I'll start off ,right up front, by saying that I know nothing about networking. So please bear with me. I am just trying to learn, I have no deadlines. I have no real projects.
OK. So, with the help of this forum, by searching for code, I stumbled across "Peer to Peer" networking. I think I know what that is.
Question #1. Most of what I saw was pretty old. At least 15 to 25 years old. Is this technology still useful, pertinent, still used?
So , I wrote 2 programs, One Server side and one client side. I learned that you can use a special remotehost value ("127.0.0.1") to test both programs on the same computer. These programs just sent a text to each other. These programs, amazingly work just fine.
Question #2. I want to put the client program on another computer. I think I have to change the remotehost value (probably in both programs. I am not sure what I should change it to.
Both computers are on the same network(I think). Both are wirelessly connected to my ISP's router. When I check the DSN(don't know what I'm talking about here, the "IPv4 address" values on both computers are the same. Also the "IPv4 DNS Servers" values are the same.
I don't even know if I need that info. I don't even know how to write the question.
What I do know is. If I go to file explorer and open the network folder, I can see the other computer listed. I cannot drill down. It need a pswd. I never bothered to figure that out.
Thanks
-
Jul 19th, 2022, 01:12 PM
#2
Member
Re: Some General Networking Questions
Personally, they work very well for me.
I recommend you put a Label on the server.
Code:
Label1.Caption = Winsock1.LocalIP
to know the IP to which the client will connect
-
Jul 19th, 2022, 01:42 PM
#3
Re: Some General Networking Questions
Since this is a home LAN can we assume you maintain proper discipline and give each machine a unique name and the same Workgroup name when you set up networking?
If so, you can just make use of the names and never have to fiddle with raw IP addresses. Client builds of Windows always include WINS as a default installation option, and winsock name resolution normally checks WINS before DNS anyway.
-
Jul 19th, 2022, 02:41 PM
#4
Thread Starter
Fanatic Member
Re: Some General Networking Questions
Dilettante, I have no idea what you said. My cable provider set us up. I have no ideaa what they did.
I believe I know the names we have given to our computers. The names show up on our lock screens, and yes, they are different.
The server code has in it
Code:
Winsock1.LocalPort = 5555
Winsock1.Listen
The client code has in it
Code:
Winsock1.Connect Winsock1.Connect "127.0.0.1", 5555
I think you are saying, in the client code replace "127.0.0.1" with the name of my computer as it displays on the lockin screen/
-
Jul 19th, 2022, 03:19 PM
#5
Re: Some General Networking Questions
As far as I can recall that only works if the computers are in the same Workgroup.
Try opening a command prompt window, then enter: nbtstat -n to retrieve the list of known names.
-
Jul 19th, 2022, 03:45 PM
#6
Thread Starter
Fanatic Member
Re: Some General Networking Questions
I cannot run it. The screen flashes. A black area is dispayed for about a nanosecond and dissapears.
However, on a more positive note. in File Explorer, I can click on networks, I found mine. I placed it into the client program an it worked. When I misstyped it, it did not work. So I guess I got it. Looks like I don't need it in the server program. I'll find out when I compile and move ther client program to the other computer.
-
Jul 19th, 2022, 04:33 PM
#7
Re: Some General Networking Questions
Originally Posted by AccessShell
I cannot run it. The screen flashes. A black area is dispayed for about a nanosecond and dissapears.
Try adding cmd /k in front of the command e.g. cmd /k nbtstat -n
You can type this whole command in File Explorer's address bar and it will start the black console in the folder File Explorer currently is in which can be handy sometimes.
In the black console you can type start . (that's a dot) to open File Explorer in console's current folder which can be handy to delete a file for instance.
Enough incantations already. Go try these :-))
cheers,
</wqw>
-
Jul 19th, 2022, 05:20 PM
#8
Thread Starter
Fanatic Member
Re: Some General Networking Questions
wqweto, you suggestion worked just fine. I got the node addr. My computer name is listed twice, both unique, both registered. One has <20>, other <00> for status. I also have another entry named WORKGROUP <00>, status = group. Local area connection is 2. I DO NOT see the computer name of the other computer.
-
Jul 20th, 2022, 01:36 AM
#9
Re: Some General Networking Questions
Originally Posted by AccessShell
I'll start off ,right up front, by saying that I know nothing about networking. So please bear with me. I am just trying to learn, I have no deadlines. I have no real projects.
OK. So, with the help of this forum, by searching for code, I stumbled across "Peer to Peer" networking. I think I know what that is.
Question #1. Most of what I saw was pretty old. At least 15 to 25 years old. Is this technology still useful, pertinent, still used?
So , I wrote 2 programs, One Server side and one client side. I learned that you can use a special remotehost value ("127.0.0.1") to test both programs on the same computer. These programs just sent a text to each other. These programs, amazingly work just fine.
Question #2. I want to put the client program on another computer. I think I have to change the remotehost value (probably in both programs. I am not sure what I should change it to.
Both computers are on the same network(I think). Both are wirelessly connected to my ISP's router. When I check the DSN(don't know what I'm talking about here, the "IPv4 address" values on both computers are the same. Also the "IPv4 DNS Servers" values are the same.
I don't even know if I need that info. I don't even know how to write the question.
What I do know is. If I go to file explorer and open the network folder, I can see the other computer listed. I cannot drill down. It need a pswd. I never bothered to figure that out.
Thanks
Question 1. - On an IPv4 network, 127.0.0.1 is known as the loopback address. I presume you are communicating using TCP/IP.
Question 2. - You are probably operating on a local area network (LAN) using an IP address 192.168.x.x. These are normally routed through a NAT router to the Wide Area Network (WAN) using a single IP address. To the outside world, you appear to be using that address, not the local one. To verify this, run the command "ipconfig /all" at the command prompt. You will probably be connected via Ethernet or WiFi. Whichever one you are using will list something like this:
IPv4 Address. . . . . . . . . . . : 192.168.0.2
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1
DNS Servers . . . . . . . . . . . : 192.168.0.1
You can communicate directly with another computer on the same network by using the IP address of that computer, or by giving it a name and adding that name & IP to the HOSTS file. Whichever route you take, you should make sure that both machines are assigned a static address and not a dynamically assigned one.
J.A. Coutts
-
Jul 20th, 2022, 08:37 AM
#10
Thread Starter
Fanatic Member
Re: Some General Networking Questions
couttsj, thank you. I will evaluate.
The IP4v number. I take it that's an address. Is it also called the DNS. In any case, I know it is an important number to connect if you are not on a LAN. But beyond that. I have seen screen shots of chats programs. I see this number displayed on the screen. Is that safe. Soud it not be hidden and a "nickname" be displayed.
-
Jul 20th, 2022, 06:14 PM
#11
Thread Starter
Fanatic Member
Re: Some General Networking Questions
Testing Results:
On same computer: Loopbask addr, Works; Computer Name, Works; IPv4 Addr, Works
On Another computer same network: ERROR
I don't know how to fix this
NOTE: The other computer does not have VB6 on it. I have placed several VB6 programs on it with no problems.
Last edited by AccessShell; Jul 20th, 2022 at 07:00 PM.
-
Jul 21st, 2022, 01:50 AM
#12
Re: Some General Networking Questions
Originally Posted by AccessShell
Testing Results:
On same computer: Loopbask addr, Works; Computer Name, Works; IPv4 Addr, Works
On Another computer same network: ERROR
I don't know how to fix this
NOTE: The other computer does not have VB6 on it. I have placed several VB6 programs on it with no problems.
MSWINSCK.OCX is a VB6 component that your program is using and must be installed on the target computer. Even though modern Windows computers have a lot of the required components already installed, MSWINSCK is not one of them. You cannot just copy the executable file, nor can you just copy the OCX file. It must be installed properly and registered with the operating system. You can do this by creating an install program.
J.A. Coutts
-
Jul 21st, 2022, 02:02 AM
#13
Re: Some General Networking Questions
Originally Posted by AccessShell
couttsj, thank you. I will evaluate.
The IP4v number. I take it that's an address. Is it also called the DNS. In any case, I know it is an important number to connect if you are not on a LAN. But beyond that. I have seen screen shots of chats programs. I see this number displayed on the screen. Is that safe. Soud it not be hidden and a "nickname" be displayed.
On the Wide Area Network (WAN), the IP address is what is used to connect 2 machines. That address is assigned by your Internet Service Provider (ISP). The Internet does not understand names, but you can register a Domain name with a Domain Name Service (DNS) provider and assign that address to it. Then when someone wants to connect to you via the Domain name, they would query the DNS server and translate the Domain name to the IP address. By adding that information to the HOSTS file provides a shorter path without having to register the name.
J.A. Coutts
Last edited by couttsj; Jul 21st, 2022 at 02:05 AM.
-
Jul 22nd, 2022, 08:28 AM
#14
Thread Starter
Fanatic Member
Re: Some General Networking Questions
On the client side, when I connect and the server (host) is not active (not on line, whatever you call it), I trigger no error msg.
Code:
Private Sub cmdConnect_Click()
On Error GoTo ConnectError
Winsock1.Connect REMOTEHOSTNAME, 5555 'instruct it to connect
Exit Sub
ConnectError:
Debug.Print "Host not available - try again later"
End Sub
What am I missing?
-
Jul 22nd, 2022, 09:16 AM
#15
Re: Some General Networking Questions
Originally Posted by AccessShell
On the client side, when I connect and the server (host) is not active (not on line, whatever you call it), I trigger no error msg.
Code:
Private Sub cmdConnect_Click()
On Error GoTo ConnectError
Winsock1.Connect REMOTEHOSTNAME, 5555 'instruct it to connect
Exit Sub
ConnectError:
Debug.Print "Host not available - try again later"
End Sub
What am I missing?
That is a code problem. The Winsock control does not generate an error when it does not connect. When it successfully connects, it generates a Winsock1_Connect Event.
Is this code your own, or did you download it from somewhere? It may help you understand networking better if you examine:
https://www.vbforums.com/showthread....B6-Simple-Sock
There are a number of limitations to MSWINSCK, and this is my own replacement for the Winsock Control. It works slightly different from MSWINSCK, but the description should help.
J.A. Coutts
-
Jul 22nd, 2022, 10:10 AM
#16
Thread Starter
Fanatic Member
Re: Some General Networking Questions
The code I have is taken from a few sources. But basically it is NOT my own.
I tried to read your suggestion https://www.vbforums.com/showthread....B6-Simple-Sock.
Suffice it to say, It is way beyond me. I did not download the code yet. Maybe seeing that will make your discussion easier to understand.
Bottom line is - using winsock1 will not produce the error.
-
Jul 22nd, 2022, 10:28 AM
#17
Re: Some General Networking Questions
Originally Posted by AccessShell
On the client side, when I connect and the server (host) is not active (not on line, whatever you call it), I trigger no error msg.
Code:
Private Sub cmdConnect_Click()
On Error GoTo ConnectError
Winsock1.Connect REMOTEHOSTNAME, 5555 'instruct it to connect
Exit Sub
ConnectError:
Debug.Print "Host not available - try again later"
End Sub
What am I missing?
You are missing that Winsock control (and networking in general) is asynchronous. When you execute Winsock1.Connect no connection is established. The Winsock control *starts* connection establishment. This might take 5 seconds and your cmdConnect_Click would be long ago executed so no way your error handler can be honored.
Winsock control has no timeouts so you have to implement timeouts on you own -- manually with a Timer control. The idea is that you issue a Connect and start waiting for connection establishment (event Connect being raised) by enabling a timer control which waits for 5 seconds. If Timer1_Timer comes before Winsock1_Connect you have a timeout.
These are the gory details of low level networking. In wrapper classes and controls you have sychronous calls with timeouts but lack flexibility.
Another thing to notice is that there is Winsock1_Error event which might be a good idea to implement to see what comes in Description parameter and when.
cheers,
</wqw>
-
Jul 22nd, 2022, 12:49 PM
#18
Thread Starter
Fanatic Member
Re: Some General Networking Questions
Thanks wqweto. The Winsock1_Error event is just what I needed. Now I can tell if the Client made the connection and notify the client.
-
Jul 23rd, 2022, 06:42 PM
#19
Thread Starter
Fanatic Member
Re: Some General Networking Questions
Ok. With your help, I got the the P2P program working. More importantly, I learned a lot about winsock, some of what it can do, and I saw some code that I never saw before.
Before I mark this thread resolved, I have one more question.
If either the host, or the client(s) is minimized, how do you get the tab in the taskbar to flash if a msg comes in?
Thanks
Last edited by AccessShell; Jul 23rd, 2022 at 07:00 PM.
-
Jul 23rd, 2022, 09:30 PM
#20
Thread Starter
Fanatic Member
Re: Some General Networking Questions
OK. I figured out post #19.
I can change the form caption every timer interval = 1000. Or I can have two form icons, same words but different colors and switch back and forth every 1000 timer intervals until the form is not minimized.
-
Jul 24th, 2022, 04:38 AM
#21
Re: [RESOLVED] Some General Networking Questions
There are FlashWindow and FlashWindowEx API functions too.
-
Jul 25th, 2022, 06:35 AM
#22
Thread Starter
Fanatic Member
Re: [RESOLVED] Some General Networking Questions
-
Jul 25th, 2022, 06:37 AM
#23
Thread Starter
Fanatic Member
Re: [RESOLVED] Some General Networking Questions
Is it easy, without excessive API code or a User control, to change the font size and color of the form caption?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|