Sending ASCII Messages to a TCP Socket

  • Hi,
    I was just wondering what the easiest way would be to send an ASCII
    string to a device that requires a TCP connection would be. I am
    fairly new to Cocoa as well as network programming so any advice
    would be appreciated.

    Thanks in advance,
    Ben
  • On Oct 15, 2006, at 3:08 PM, Ben Barry wrote:

    > Hi,
    > I was just wondering what the easiest way would be to send an ASCII
    > string to a device that requires a TCP connection would be. I am
    > fairly new to Cocoa as well as network programming so any advice
    > would be appreciated.

    Look at NSSocketPort and its parent class NSPort.

    -Shawn
  • Shawn,
    it looks as if it might work. But forgive my ignorance here, when I
    ask how do I use it? How do I tell it the IP address of the device ?
    Sorry, like I said this is all new to me.

    Ben

    On Oct 15, 2006, at 5:13 PM, Shawn Erickson wrote:

    >
    > On Oct 15, 2006, at 3:08 PM, Ben Barry wrote:
    >
    >> Hi,
    >> I was just wondering what the easiest way would be to send an
    >> ASCII string to a device that requires a TCP connection would be.
    >> I am fairly new to Cocoa as well as network programming so any
    >> advice would be appreciated.
    >
    > Look at NSSocketPort and its parent class NSPort.
    >
    > -Shawn
  • On 15 Oct 2006, at 3:13 PM, Shawn Erickson wrote:

    > On Oct 15, 2006, at 3:08 PM, Ben Barry wrote:
    >
    >> Hi,
    >> I was just wondering what the easiest way would be to send an
    >> ASCII string to a device that requires a TCP connection would be.
    >> I am fairly new to Cocoa as well as network programming so any
    >> advice would be appreciated.
    >
    > Look at NSSocketPort and its parent class NSPort.
    >
    > -Shawn

    Isn't NSSocketPort and NSPort for Distributed Objects? Perhaps Ben
    Barry should look at NSStream instead.

    file:///Developer/ADC%20Reference%20Library/documentation/Cocoa/
    Reference/Foundation/Classes/NSStream_Class/Reference/
    Reference.html#//apple_ref/occ/clm/NSStream/
    getStreamsToHost:port:inputStream:outputStream:
  • On Oct 15, 2006, at 11:20 PM, Dustin Voss wrote:

    > On 15 Oct 2006, at 3:13 PM, Shawn Erickson wrote:
    >
    >> On Oct 15, 2006, at 3:08 PM, Ben Barry wrote:
    >>
    >>> Hi,
    >>> I was just wondering what the easiest way would be to send an
    >>> ASCII string to a device that requires a TCP connection would be.
    >>> I am fairly new to Cocoa as well as network programming so any
    >>> advice would be appreciated.
    >>
    >> Look at NSSocketPort and its parent class NSPort.
    >>
    >> -Shawn
    >
    > Isn't NSSocketPort and NSPort for Distributed Objects? Perhaps Ben
    > Barry should look at NSStream instead.

    Likely... but for all we know http put is what he needs which would
    mean that CFURL access utilities may be more correct.

    -Shawn
  • I've looked at all of the recommendations and I am unsure as to which
    would make more sense, NSStream looks as though it would be simpler
    to implement, but I'm not sure what I should be looking for.

    The device I want to connect to is has a static IP and I would need
    to send a message like:
    "getstatus" on port 4998.

    Would one work better then the other for something like that?

    Ben
    On Oct 16, 2006, at 10:54 AM, Shawn Erickson wrote:

    >
    > On Oct 15, 2006, at 11:20 PM, Dustin Voss wrote:
    >
    >> On 15 Oct 2006, at 3:13 PM, Shawn Erickson wrote:
    >>
    >>> On Oct 15, 2006, at 3:08 PM, Ben Barry wrote:
    >>>
    >>>> Hi,
    >>>> I was just wondering what the easiest way would be to send an
    >>>> ASCII string to a device that requires a TCP connection would
    >>>> be. I am fairly new to Cocoa as well as network programming so
    >>>> any advice would be appreciated.
    >>>
    >>> Look at NSSocketPort and its parent class NSPort.
    >>>
    >>> -Shawn
    >>
    >> Isn't NSSocketPort and NSPort for Distributed Objects? Perhaps Ben
    >> Barry should look at NSStream instead.
    >
    > Likely... but for all we know http put is what he needs which would
    > mean that CFURL access utilities may be more correct.
    >
    > -Shawn
  • On Oct 16, 2006, at 10:21 AM, Ben Barry wrote:

    > The device I want to connect to is has a static IP and I would need
    > to send a message like:
    > "getstatus" on port 4998.

    What do you mean by "message"?

    Is it just a plain ASCII string sent to that port? Is it an HTTP
    request? etc.
    What happens when the device gets this message? Are you expecting
    data to come back? If so what form is that data in?

    If I had to guess I bet you are trying to interface with a Global
    Caché device (based on the port involved). If that is the case then
    what the following API docs outline <http://www.globalcache.com/files/
    Documentation/API_GC-100.pdf
    > is the sending of ASCII strings... in
    other words NSStream and friends are likely the best fit at the Cocoa
    level.

    Review... <http://developer.apple.com/documentation/Cocoa/Conceptual/
    Streams/index.html
    >

    -Shawn _______________________________________________
    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list      (<Cocoa-dev...>)
    Help/Unsubscribe/Update your Subscription:
    http://lists.apple.com/mailman/options/cocoa-dev/<cocoa...>

    This email sent to <cocoa...>
  • On Oct 15, 2006, at 3:08 PM, Ben Barry wrote:

    > I was just wondering what the easiest way would be to send an ASCII
    > string to a device that requires a TCP connection would be. I am
    > fairly new to Cocoa as well as network programming so any advice
    > would be appreciated.

    This should be fairly straightforward with NSStream.  Specifically,
    check out the documentation for the NSStream class method +[NSStream
    getStreamsToHost:port:inputStream:outputStream:].  Given an NSHost and
    a port, it can return an open NSInputStream and NSOutputStream that
    you can use to communicate with it.

    Don't bother looking at NSPort and NSSocketPort for this; those
    classes are for use with Distributed Objects, not for implementing
    generic networking protocol support.

      -- Chris
  • Thanks Shawn ! I'll keep plugging away with the NSStream stuff.
    On Oct 16, 2006, at 12:45 PM, Shawn Erickson wrote:

    >
    > On Oct 16, 2006, at 10:21 AM, Ben Barry wrote:
    >
    >> The device I want to connect to is has a static IP and I would
    >> need to send a message like:
    >> "getstatus" on port 4998.
    >
    > What do you mean by "message"?
    >
    > Is it just a plain ASCII string sent to that port? Is it an HTTP
    > request? etc.
    > What happens when the device gets this message? Are you expecting
    > data to come back? If so what form is that data in?
    >
    > If I had to guess I bet you are trying to interface with a Global
    > Caché device (based on the port involved). If that is the case then
    > what the following API docs outline <http://www.globalcache.com/
    > files/Documentation/API_GC-100.pdf> is the sending of ASCII
    > strings... in other words NSStream and friends are likely the best
    > fit at the Cocoa level.
    >
    > Review... <http://developer.apple.com/documentation/Cocoa/
    > Conceptual/Streams/index.html>
    >
    > -Shawn
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today