-
Feb 15th, 2018, 10:23 AM
#1
Thread Starter
New Member
Receiving data from port
Hi hi,
I am new here and I have one problem to solve.
I need to take all data sending by one specific computer to the lan. Could you help me with this?
All information about this computer:
IPServer=0; IPAddress=192.168.2.20; IPPort=1008; Portnum=99.
I will be very grateful if you help me.
-
Feb 15th, 2018, 10:49 AM
#2
Re: Receiving data from port
How is it sending? Most likely, it is either UDP or TCP. Hopefully, it is UDP, as I'm not sure that TCP can broadcast. Those two are by far the most likely protocols involved.
My usual boring signature: Nothing
-
Feb 15th, 2018, 11:14 AM
#3
Thread Starter
New Member
Re: Receiving data from port
There is no information if it's using UDP or TCP. I found function TcpListener can it capture data?
-
Feb 15th, 2018, 11:22 AM
#4
Thread Starter
New Member
Re: Receiving data from port
I found manual. It's written there shortly only about TCP
-
Feb 15th, 2018, 12:15 PM
#5
Re: Receiving data from port
TCP is a connection based protocol. With TCP, you'd have to establish a connection with the other computer, then that other computer would send data through the connection. That doesn't sound much like what you are talking about, but what you are talking about sounds pretty vague.
If the one data is sending out data, then who is it sending it to, and how is it sending it? Those are the questions you need to be able to answer. Communication will follow some kind of protocol, otherwise it is just garbage to the receiver. That protocol will define how the data is packaged, and will add some stuff to it for routing purposes, kind of like you might put an address on a letter. If you were just to see bytes, you'd see the address and the payload, and would have a fun time figuring out which was which. Furthermore, since the message will be broken up into chunks, unless it is very small, then all you'd see is a part of the package. TCP manages both chopping the whole message into packets, as well as stitching the packets back together on the receiving end, and asking for packets that failed to make it. So, there's a fair amount involved to communication between computers, and TCP takes care of most of that.
UDP is simpler, but is effectively the same thing, except that there isn't a connection. The data is still in packets, and there is still some addressing stuff attached to each packet, but there is no stitching it back together. If a packet is lost, or duplicated (it can happen), UDP doesn't care. You get the missing data, the duplicated data, data out of order, and so on. Therefore, UDP tends to be used for small data such that all the data in a transmission is contained within a single packet.
There's a fair amount more than that to it, but you may be getting the picture that you need to understand a lot more about what it is you are trying to do, because the data will be in chunks with other stuff attached to it.
Perhaps you'd be better off explaining what it is you are trying to achieve with a more complete description of the problem you are trying to solve.
My usual boring signature: Nothing
-
Feb 20th, 2018, 09:08 AM
#6
Thread Starter
New Member
Re: Receiving data from port
Problem solved, please close topic
-
Feb 20th, 2018, 10:13 AM
#7
Re: Receiving data from port
We don't close threads just because they are resolved. However, you can set it to resolved yourself. That's found on the Thread Tools menu.
My usual boring signature: Nothing
-
Feb 25th, 2018, 12:13 PM
#8
Thread Starter
New Member
Re: Receiving data from port
Ok thank you Shaggy Hiker.
Here is my code. It's connecting to selected socket. I have another problem to solve. This code takes only first thing which is send through socket.. how to make this program keeping listening on socket alive all the time? I tried with Do Loop but it's multiply this one info and add to list box a lot.
Code:
Private Sub hosting_port()
Const portNumber As Integer = 1008
Dim tcpListener As New TcpListener(portNumber)
tcpListener.Start()
ListBox1.Items.Add("Waiting for connection")
Try
'Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect("192.168.2.20", 1008)
ListBox1.Items.Add("Connected")
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim cliendata As String = Encoding.ASCII.GetString(bytes)
ListBox1.Items.Add((cliendata))
Catch ex As Exception
ListBox1.Items.Add(ex.Message)
End Try
End Sub
Private Sub multi_server()
Dim thread As System.Threading.Thread
thread = New System.Threading.Thread(AddressOf hosting_port)
thread.Start()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
multi_server()
End Sub
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
|