Hi
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:
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:
Please, Any Ideas?
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:
Private Sub Form_Load()
'First Close Connection
Winsock1.Close
'Winsock Port
Winsock1.LocalPort = "8881"
'Listen Connection
Winsock1.Listen
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
Winsock1.Close
Call Form_Load
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
'CLose Socket
Winsock1.Close
'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:
Imports System.Net.Sockets
Imports System.Text
Imports System.Net
Public Class Form1
Dim portNo As Integer = 8881
Dim IP As IPAddress = IPAddress.Parse("127.0.0.1")
Dim listener As New TcpListener(IP, portNo)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
listener.Start()
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?