|
-
Aug 19th, 2008, 08:06 AM
#1
Thread Starter
New Member
IMS Connect
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,
John
vb.net Code:
Imports 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
Last edited by Hack; Aug 20th, 2008 at 06:38 AM.
Reason: Added Highlight Tags
-
Aug 19th, 2008, 03:15 PM
#2
Re: IMS Connect
Welcome to the forums.
The Read method is a synchronous blocking method, so the execution will halt there until something has been read from the stream (or until a certain timeout has been triggered, if any).
This must mean that the server you're connecting too isnt sending anything back to you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|