Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


TCP Connection VB 2010 for receiving ascii

TCP Connection VB 2010 for receiving ascii

TCP Connection VB 2010 for receiving ascii

I'm trying to make a program in VB 2010 for receiving calls information from PBX via TCP, I already has a programa in VB 6.0 using Winsock TCPProtocol that receive the calls made and show them in Textbox, this is the VB 6.0 program:

CODE --> 6

Private Sub Form_Load()
    'First Close Connection
    'Winsock Port
    Winsock1.LocalPort = "8881"
    'Listen Connection
End Sub
'Data Arrival
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
        Winsock1.GetData Buffer
        'Show Information received
        Text7.Text = Buffer & Text7.Text
End Sub
Private Sub Winsock1_Close()
    'Close Connection
    Call Form_Load
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    'CLose Socket
    'Accept Connection
    Winsock1.Accept requestID
End Sub 

The calls information that sends the PBX is in Ascii:
2015/07/13 08:50:49,00:00:00,0,226,O,9184,9184,,0,1002018,0,E226,Joe P.,T9006,Line 6.0,0,0,n/a,0,,,,,,,,,U,Joe P.,

I found out that I can use TCP listener in VB 2010 for receiving the ascii information that send the PBX (I dont know if tcp listener is right way to do it), I'm using this code that I got from the web for getting ascii information and show it in textbox for It makes nothing:

CODE --> 2010

Imports System.Net.Sockets
Imports System.Text
Imports System.Net
Public Class Form1
    Dim portNo As Integer = 8881
    Dim IP As IPAddress = IPAddress.Parse("")
    Dim listener As New TcpListener(IP, portNo)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim tcpClient As TcpClient = listener.AcceptTcpClient()
        Dim ns As NetworkStream = tcpClient.GetStream
        Dim data(tcpClient.ReceiveBufferSize) As Byte
        '---read incoming stream; Read() is a blocking call---
        Dim numBytesRead As Integer = ns.Read(data, 0, CInt(tcpClient.ReceiveBufferSize))
        '---display data received---
        TextBox1.Text = Encoding.ASCII.GetString(data, 0, numBytesRead)
        Console.WriteLine("Received :" & Encoding.ASCII.GetString(data, 0, numBytesRead))
    End Sub
End Class 

Please, Any Ideas?

RE: TCP Connection VB 2010 for receiving ascii

I don't know if you've worked this out yet, and I haven't work with the TcpListener, TcpClient, or VB in years - but I have an idea.

Based on what I can see of your code, you are creating a listener that listens on This is I believe were you are having issues.

When you specify the endpoint of the listener, it will listen specifically on that endpoint - in this case the localhost. Your PBX would not be connecting to the localhost interface, so chances are you aren't even getting past the AcceptTcpClient line.

Instead of using IPAddress.Parse("") you should be using IPAddress.IPv6Any or IPAddress.Any. Those two should allow your listener to accept the incoming connection from an outside source (such as your PBX).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close