Results 1 to 2 of 2

Thread: IMS Connect

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2006
    Posts
    12

    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:
    1. Imports System.Net.Sockets  
    2. Imports System.Text  
    3.  
    4. Class CTestTCPClient  
    5.     Shared Sub Main()  
    6.         Dim strHostName As String = "xxx.xxx.xxx.xxx"  
    7.          Dim intPortNumber As Int32 = 9999  
    8.         Dim tcpClient As New System.Net.Sockets.TcpClient  
    9.         tcpClient.Connect(strHostName, intPortNumber)  
    10.         Dim networkStream As NetworkStream = tcpClient.GetStream()  
    11.         If networkStream.CanWrite And networkStream.CanRead Then  
    12.             Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Is anybody listening...")  
    13.             networkStream.Write(sendBytes, 0, sendBytes.Length)  
    14.             ' Read the NetworkStream into a byte buffer.  
    15.               Dim bytes(tcpClient.ReceiveBufferSize) As Byte  
    16.             Console.WriteLine("About to get buffer size")  
    17.  
    18.             ' It hangs on this line:  
    19.  
    20.             networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))  
    21.  
    22.             ' Output the data received from the host to the console.  
    23.             Dim returndata As String = Encoding.ASCII.GetString(bytes)  
    24.             Console.WriteLine(("TCP Server returned: " + returndata))  
    25.         Else  
    26.             If Not networkStream.CanRead Then  
    27.                 Console.WriteLine("Could not write data to data stream")  
    28.                 tcpClient.Close()  
    29.             Else  
    30.                 If Not networkStream.CanWrite Then  
    31.                     Console.WriteLine("Could not read data from data stream")  
    32.                     tcpClient.Close()  
    33.                 End If  
    34.             End If  
    35.         End If  
    36.         ' Pause to let the user view the console output.  
    37.         Console.ReadLine()  
    38.     End Sub  
    39. End Class
    Last edited by Hack; Aug 20th, 2008 at 06:38 AM. Reason: Added Highlight Tags

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width