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.
18 posts Page 2 of 2
Contributors
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Re: Client socket
AnoPem
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
https://t.me/pump_upp
User avatar
benji_19994
VIP - Donator
VIP - Donator
Posts: 156
Joined: Mon Apr 16, 2012 3:13 pm

Re: Client socket
benji_19994
Does your phones upper wan?
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Re: Client socket
AnoPem
benji_19994 wrote:
Does your phones upper wan?
What do you mean? ive been trying from my school today with the same result
https://t.me/pump_upp
User avatar
benji_19994
VIP - Donator
VIP - Donator
Posts: 156
Joined: Mon Apr 16, 2012 3:13 pm

Re: Client socket
benji_19994
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.
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Re: Client socket
AnoPem
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
server.zip
You do not have the required permissions to view the files attached to this post.
https://t.me/pump_upp
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Client socket
mandai
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
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Re: Client socket
AnoPem
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() ).

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
Im not quiet sure on how i should use that, can you help me out?
https://t.me/pump_upp
User avatar
dan2130
VIP - Donator
VIP - Donator
Posts: 104
Joined: Sat Sep 26, 2009 3:39 am

Re: Client socket
dan2130
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.
admin@adosrv.net
Owner of ado-srv.net softwares network.
18 posts Page 2 of 2
Return to “Coding Help & Support”