Thread: Few Socket Questions

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    17

    Few Socket Questions

    I'm 100% new to programming C w/ connecting to other computers, listening for it, sending/recieving packets basically. Well I have this one program send a packet to a server, where there's a program listening for it - if it gets it i know that inet_ntoa(si_other.sin_addr) is the IP that's connecting to the program, how can I make it check this against a string, having a few problems with that o.o Thanks

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1) Convert an integer to a string and compare them using something like strcmp.
    2) Convert the string to an integer, and compare them directly.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    17
    Thanks a ton Got it working

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    17
    One last question, how can I have it read a file line by line to check if a certian string is there? Thanks.

  5. #5
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    If you're already on to sockets I'm gonna assume you already know about the file functions. To find a substring of a string see strstr . If You don't know then check the FAQ and or here .
    Last edited by caroundw5h; 11-29-2004 at 12:02 AM.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  6. #6
    Registered User
    Join Date
    Jul 2004
    Posts
    17
    strstr, thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. socket programming question, closing sockets...
    By ursula in forum Networking/Device Communication
    Replies: 2
    Last Post: 05-31-2009, 05:17 PM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Simple Socket Questions
    By Kristian_ in forum Networking/Device Communication
    Replies: 3
    Last Post: 07-02-2004, 03:02 PM
  4. Socket Questions
    By elitesyntax in forum C++ Programming
    Replies: 4
    Last Post: 04-28-2004, 09:28 PM
  5. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM