Thread: Need help with sending an int via sockets.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    3

    Post Need help with sending an int via sockets.

    Howdy all,

    I've been having touble trying to get my head around how (UNIX) sockets actually send and receive an int or an int variable via a streaming socket.

    I have a value (int px) and I have a socket (sa) and connect (c), and wish to send it from the server to the client. My understanding is that it goes something along these lines:

    For the server:

    Code:
    send(sa, &px, sizeof(px), 0);
    Then I have in the client code:

    Code:
    recv(c, &px, sizeof(px), 0)
    Though whatever I send (just an int) ends up casting a floating point exception to the client. Can anyone see where I'm going wrong, or offer some advice?

    Thanks in advance.
    Last edited by pheeze; 11-10-2009 at 01:18 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. NEED HELP READING FILE and PRINTING
    By geoffr0 in forum C Programming
    Replies: 4
    Last Post: 04-16-2009, 05:26 PM
  2. memory leak
    By aruna1 in forum C++ Programming
    Replies: 3
    Last Post: 08-17-2008, 10:28 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM

Tags for this Thread