Few Socket Questions

This is a discussion on Few Socket Questions within the C Programming forums, part of the General Programming Boards category; I'm 100% new to programming C w/ connecting to other computers, listening for it, sending/recieving packets basically. Well I have ...

  1. #1
    Ne0
    Ne0 is offline
    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
    Ne0
    Ne0 is offline
    Registered User
    Join Date
    Jul 2004
    Posts
    17
    Thanks a ton Got it working

  4. #4
    Ne0
    Ne0 is offline
    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
    Ne0
    Ne0 is offline
    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, 06: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, 06:36 AM
  3. Simple Socket Questions
    By Kristian_ in forum Networking/Device Communication
    Replies: 3
    Last Post: 07-02-2004, 04:02 PM
  4. Socket Questions
    By elitesyntax in forum C++ Programming
    Replies: 4
    Last Post: 04-28-2004, 10: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, 12:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21