Client socket
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
benji_19994 wrote:Most phones don't allow port forwarding.Im not port fowarding on my phone, im sharing my connection so that i can try to connet to my server from another ip. which means the pc which the server is on has been port fowarded in the router
benji_19994 wrote:Does your phones upper wan?What do you mean? ive been trying from my school today with the same result
Can you paste the server connecting and listening part of your code here and before I ment does you phones Internet support wide area network.
benji_19994 wrote:Can you paste the server connecting and listening part of your code here and before I ment does you phones Internet support wide area network.Yes, and its not because of my phone
This is the code in my client, and i have attatched the server as a zip
Code: Select all
Imports System.Net.Sockets
Imports System.Text
Public Class connect
Dim clientSocket As New System.Net.Sockets.TcpClient()
Dim serverStream As NetworkStream
Dim readData As String
Dim infiniteCounter As Integer
Private Sub msg()
If Me.InvokeRequired Then
Me.Invoke(New MethodInvoker(AddressOf msg))
Else
TextBox1.Text = TextBox1.Text + Environment.NewLine & readData
End If
End Sub
Private Sub getMessage()
Try
For infiniteCounter = 1 To 2
infiniteCounter = 1
serverStream = clientSocket.GetStream()
Dim buffSize As Integer
Dim inStream(10024) As Byte
buffSize = clientSocket.ReceiveBufferSize
serverStream.Read(inStream, 0, buffSize)
Dim returndata As String = _
System.Text.Encoding.ASCII.GetString(inStream)
readData = "" + returndata
msg()
Next
Catch ex As Exception
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
readData = "Connecting to Server ..."
msg()
clientSocket.Connect(IpText.Text, 8888)
serverStream = clientSocket.GetStream()
Dim outStream As Byte() = _
System.Text.Encoding.ASCII.GetBytes("" + "$")
serverStream.Write(outStream, 0, outStream.Length)
serverStream.Flush()
Dim ctThread As Threading.Thread = New Threading.Thread(AddressOf getMessage)
ctThread.Start()
Catch ex As Exception
MsgBox(ex.Message)
Clipboard.SetText(ex.Message)
End Try
End Sub
You do not have the required permissions to view the files attached to this post.
It is likely you are seeing the issue because the server is not buffering the client's data correctly (on a wide area network you must assume the data won't always arrive in a single frame / a single NetworkStream.Read() ).
It is a better practice to store the responses until it matches a defined header/trailer (this depends on your protocol design).
I would recommend you look at some of the samples that work in this way. A while back I made a chat system like this: viewtopic.php?f=29&t=6747&p=50222#p50222
It is a better practice to store the responses until it matches a defined header/trailer (this depends on your protocol design).
I would recommend you look at some of the samples that work in this way. A while back I made a chat system like this: viewtopic.php?f=29&t=6747&p=50222#p50222
mandai wrote:It is likely you are seeing the issue because the server is not buffering the client's data correctly (on a wide area network you must assume the data won't always arrive in a single frame / a single NetworkStream.Read() ).Im not quiet sure on how i should use that, can you help me out?
It is a better practice to store the responses until it matches a defined header/trailer (this depends on your protocol design).
I would recommend you look at some of the samples that work in this way. A while back I made a chat system like this: viewtopic.php?f=29&t=6747&p=50222#p50222
When i have this kind of problem with my softwares i check if ithe external ip address is the same as the first time look at : whatismyip.org and then if its good check if you have correctly opened the socket in the router some router call it virtual servers or port forwarding and if its dosen't work then look in your computer if you have any firewall active like the Windows one or some anti-virus are verry invasive and block the socket.
I hope to had help. but these time i have some difficulties with my servers i have some errors and no data travelling i think about a problem from Framework update or something like that. if you have any other question im here to help.
I hope to had help. but these time i have some difficulties with my servers i have some errors and no data travelling i think about a problem from Framework update or something like that. if you have any other question im here to help.
admin@adosrv.net
Owner of ado-srv.net softwares network.
Owner of ado-srv.net softwares network.
Copyright Information
Copyright © Codenstuff.com 2020 - 2023