none
Using TCPClient to wait for SMS responses RRS feed

  • Question

  • I have a very basic procedure that is able to use TCPClient to authenticate with a TCP gateway and then send a series of instruction sets, each containing a number to call and a message to send.  The requests are sent and the immediate responses of the gateway are received back, and the messages are sent by the gateway.  However, the gateway is also supposed to be able to send back any subsequent replies to the SMS messages.  What is the simplest way to use the TCP framework to pick up these messages?
    • Moved by Mike Feng Thursday, February 14, 2013 9:38 AM
    Wednesday, February 13, 2013 9:10 PM

Answers

  • Just want clarification that, is the response a JSON stream only or does it have full HTTP content (i.e. with headers and response code etc.)

    If true, you may use WebClient.DownloadString() to make your life easier.

    Anyway, here's example on how to read string data from TcpClient. After read the full string by either of the above methods, you can use JSON Deserializer to decode the message.

    Thursday, February 14, 2013 9:31 AM

All replies

  • Using a 3rd party library I suppose? Some SMS gateway provider does provide their own library, and some library does not need you to learn network programming at all.

    I'll take the package provided by a local provider here for example. The package they provides includes a Windows service and a MySQL database. The service will fetch records from the database every few minutes (configurable) and send SMS out. All you have to do is insert records according to instructions provided.

    Thursday, February 14, 2013 2:08 AM
  • The gateway I am working with provides an API that accepts and returns JSON, but there is no support given for developers who must communicate with the API.  I have developed C# procedures that authenticate with the API and then can send a series of messages, each to be sent as a n SMS message to a phone number that is also provided.

    What I have difficulty with is retrieving the return SMSs, sent back to the gateway by the recipients in reply to the initial SMSs.  What I am looking for is broad guidance on the use of TCPClient to retrieve these responses.  How should it be done?

    Thursday, February 14, 2013 8:42 AM
  • Just want clarification that, is the response a JSON stream only or does it have full HTTP content (i.e. with headers and response code etc.)

    If true, you may use WebClient.DownloadString() to make your life easier.

    Anyway, here's example on how to read string data from TcpClient. After read the full string by either of the above methods, you can use JSON Deserializer to decode the message.

    Thursday, February 14, 2013 9:31 AM