kplonk
asked on
networking
i want to write a prgram that will use the tcp/ip protocal to talk between two computers on my home network. i have done this but the program works by creating special files that the other computers on the network (running the same program)can read. This is not good as all the computers have to be able to read and write to a comman area. also not that fast. Is there a way that i can do the same using gust the ip address of a computer. any ideas will be great.
ASKER
i want to make a chat progam that ueses tcp/ip. But know nothing about it
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
looks good will try but this not exactly what i wanted. What i need is a expliniation of tcp/ip and will this eventuly work over the inter net?
Yes, the code I gave you will work over the internet...
TCP/IP in 50 words or less:
TCP/IP is the communication protocol that the Internet uses to allow 2 machines to talk to eachother. Every machine on the internet has a unique TCP/IP address. This address is used to "route" the information from point A to B...
A system's connection is handled through a socket. (in the case of VB, the winsock control.) A individual connection is handled using a port number... There are several ports that are designated as "well known ports". These ports support different protocols.
For example FTP operates on port 21. So, if your IP address is 123.45.67.89 and you are running an FTP SERVER, people could connect to that address and port to transfer files...
The example of a chat server I gave you uses the winsock control and operates on port 1001. Anyone that connects to your system on port 1001 will be connected to the chat server...
Make sense???
Cheers!®©
TCP/IP in 50 words or less:
TCP/IP is the communication protocol that the Internet uses to allow 2 machines to talk to eachother. Every machine on the internet has a unique TCP/IP address. This address is used to "route" the information from point A to B...
A system's connection is handled through a socket. (in the case of VB, the winsock control.) A individual connection is handled using a port number... There are several ports that are designated as "well known ports". These ports support different protocols.
For example FTP operates on port 21. So, if your IP address is 123.45.67.89 and you are running an FTP SERVER, people could connect to that address and port to transfer files...
The example of a chat server I gave you uses the winsock control and operates on port 1001. Anyone that connects to your system on port 1001 will be connected to the chat server...
Make sense???
Cheers!®©
So it is two humans in your house (non-internet) soing a chat! I did not suspect, but in part queried on it since there are an abundance of sample code for this. Also for UDP. I thought VB included a sample(s).
I'll skip review of the proposed, you may now be happy. But caution here, be very wary about what you want to do over the internet, it is much less simple and you become that much more vulnerable. Even to access friend/family in town. ALso look up on proxy.
I'll skip review of the proposed, you may now be happy. But caution here, be very wary about what you want to do over the internet, it is much less simple and you become that much more vulnerable. Even to access friend/family in town. ALso look up on proxy.
ASKER
works well but i need to know some ideas on how to write the client as i do not want to use telnet
Using the server as a guideline, you would do the following to connect:
Winsock1.RemoteHost = "servername"
Winsock1.RemotePort = 1001
Winsock1.Connect
Then in the DataArrival event of the winsock control, you would use the winsock GetData function to read information sent to you from the server.
When you want to send data, you would use the winsock SendData function...
Cheers!®©
Winsock1.RemoteHost = "servername"
Winsock1.RemotePort = 1001
Winsock1.Connect
Then in the DataArrival event of the winsock control, you would use the winsock GetData function to read information sent to you from the server.
When you want to send data, you would use the winsock SendData function...
Cheers!®©
ASKER
i have don this but i have a problem. the text that i send top the serve is only echoed to the person who typed it and not to all the others any idase here si the code
Private Sub Form_Load()
Winsock1.RemoteHost = "192.168.0.2"
Winsock1.RemotePort = 1001
Winsock1.Connect
NL = Chr(13) + Chr(10)
End Sub
Private Sub txtText_KeyPress(KeyAscii As Integer)
Dim strData
If KeyAscii = vbKeyReturn Then
strData = txtText
Winsock1.SendData strData
txtText.Text = ""
txtMain.Text = txtMain.Text + vbCrLf
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData, vbString
txtMain.Text = txtMain.Text + strData
End Sub
thanks for all the help
Private Sub Form_Load()
Winsock1.RemoteHost = "192.168.0.2"
Winsock1.RemotePort = 1001
Winsock1.Connect
NL = Chr(13) + Chr(10)
End Sub
Private Sub txtText_KeyPress(KeyAscii As Integer)
Dim strData
If KeyAscii = vbKeyReturn Then
strData = txtText
Winsock1.SendData strData
txtText.Text = ""
txtMain.Text = txtMain.Text + vbCrLf
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal
Dim strData As String
Winsock1.GetData strData, vbString
txtMain.Text = txtMain.Text + strData
End Sub
thanks for all the help
Do you have Service Pack 3 installed? It not, you need to install it. It fixes a bunch of problems with Winsock...
Also, try DoEvents in your code... Like This:
Private Sub txtText_KeyPress(KeyAscii As Integer)
Dim strData
If KeyAscii = vbKeyReturn Then
strData = txtText
Winsock1.SendData strData
DoEvents
txtText.Text = ""
txtMain.Text = txtMain.Text + vbCrLf
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData, vbString
txtMain.Text = txtMain.Text + strData
DoEvents
End Sub
Cheers!®©
Also, try DoEvents in your code... Like This:
Private Sub txtText_KeyPress(KeyAscii As Integer)
Dim strData
If KeyAscii = vbKeyReturn Then
strData = txtText
Winsock1.SendData strData
DoEvents
txtText.Text = ""
txtMain.Text = txtMain.Text + vbCrLf
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal
Dim strData As String
Winsock1.GetData strData, vbString
txtMain.Text = txtMain.Text + strData
DoEvents
End Sub
Cheers!®©
ASKER
thanks for all the help
Thanks for the points! Glad I could help!
Cheers!®©
Cheers!®©
It looks like your current state is that you have code to move files via IP address. True? I am not clear one why you do not want your program to acces the file, since it looks like it has to also be able to create it.