John T Howad
Aug 19th, 2008, 08:06 AM
I am trying to create a simple TCP program to interact with IMS Connect on a mainframe (please see code). At this point, I'm just trying to verify that I am getting to IMS Connect on the mainframe.
The program is copied from a Microsoft example and works fine when interacting with a localhost server on the same machine. However, when going against the mainframe and IMS Connect, it hangs on the "networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))" line. I am expecting a message from the mainframe saying that the input is invalid (this isn't a message recognizable to IMS Connect yet), but I seem to get no response.
Any suggestions would be appreciated, but please keep them as simple as possible.
Thanks,
JohnImports System.Net.Sockets
Imports System.Text
Class CTestTCPClient
Shared Sub Main()
Dim strHostName As String = "xxx.xxx.xxx.xxx"
Dim intPortNumber As Int32 = 9999
Dim tcpClient As New System.Net.Sockets.TcpClient
tcpClient.Connect(strHostName, intPortNumber)
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Is anybody listening...")
networkStream.Write(sendBytes, 0, sendBytes.Length)
' Read the NetworkStream into a byte buffer.
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
Console.WriteLine("About to get buffer size")
' It hangs on this line:
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Output the data received from the host to the console.
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Console.WriteLine(("TCP Server returned: " + returndata))
Else
If Not networkStream.CanRead Then
Console.WriteLine("Could not write data to data stream")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
Console.WriteLine("Could not read data from data stream")
tcpClient.Close()
End If
End If
End If
' Pause to let the user view the console output.
Console.ReadLine()
End Sub
End Class
The program is copied from a Microsoft example and works fine when interacting with a localhost server on the same machine. However, when going against the mainframe and IMS Connect, it hangs on the "networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))" line. I am expecting a message from the mainframe saying that the input is invalid (this isn't a message recognizable to IMS Connect yet), but I seem to get no response.
Any suggestions would be appreciated, but please keep them as simple as possible.
Thanks,
JohnImports System.Net.Sockets
Imports System.Text
Class CTestTCPClient
Shared Sub Main()
Dim strHostName As String = "xxx.xxx.xxx.xxx"
Dim intPortNumber As Int32 = 9999
Dim tcpClient As New System.Net.Sockets.TcpClient
tcpClient.Connect(strHostName, intPortNumber)
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Is anybody listening...")
networkStream.Write(sendBytes, 0, sendBytes.Length)
' Read the NetworkStream into a byte buffer.
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
Console.WriteLine("About to get buffer size")
' It hangs on this line:
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Output the data received from the host to the console.
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Console.WriteLine(("TCP Server returned: " + returndata))
Else
If Not networkStream.CanRead Then
Console.WriteLine("Could not write data to data stream")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
Console.WriteLine("Could not read data from data stream")
tcpClient.Close()
End If
End If
End If
' Pause to let the user view the console output.
Console.ReadLine()
End Sub
End Class