Thread: Connecting With IP

  1. #1
    Chess Master Phanster's Avatar
    Join Date
    Oct 2004
    Posts
    8

    Connecting With IP

    Hello, I just recently joined the forum after browsing through the site for a week or so. Great forum!

    Anyways, Im planning on making a chess program where you can connect to another player through their IP address. Any suggestions on how I could do this? Also if there are any links to where I can learn any techniques on how to do so would be great

  2. #2
    Bob Dole for '08 B0bDole's Avatar
    Join Date
    Sep 2004
    Posts
    618
    research tcp/ip, sockets i think, not an expert, but thats where u start i think
    Hmm

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Google for Beej.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  4. #4
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Depending on the platform your working on, you have aceess to the BSD socket api. on linux it is as it, and microsoft has a version as well. Google for bsd sockets api if your on linux. though i'm pretty sure your not.
    Warning: Opinions subject to change without notice

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

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    361
    DirectPlay (Part of the DirectX API) would be pretty handy if you want to wet your whistle a bit.

    Otherwise, WinSock is a word that will most likely come up.

  6. #6
    Interested Newbie
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    51
    Shouldn't this be in the Network forum?

  7. #7
    Chess Master Phanster's Avatar
    Join Date
    Oct 2004
    Posts
    8

    Thanks

    Ok thanks guys, Ill search up some of these topics

  8. #8
    Chess Master Phanster's Avatar
    Join Date
    Oct 2004
    Posts
    8

    Hmmm

    I tried that Beej site, but its all Unix, Im developing this in Win32 Any other suggestions? WinSock seems alot more complicated than how I use it back in VB...

  9. #9
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Your gonna need to learn to start using google
    Warning: Opinions subject to change without notice

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

  10. #10
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  11. #11
    Arggggh DeepFyre's Avatar
    Join Date
    Sep 2004
    Posts
    227
    I used this site:
    www.gametutorials.com

    >>but its all Unix
    err...not too sure, but isnt it based off of Unix? I used that tutorial and the one above and they worked for me and I am on Windows too.
    Last edited by DeepFyre; 10-19-2004 at 08:08 PM.
    Keyboard Not Found! Press any key to continue. . .

  12. #12
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>but its all Unix, Im developing this in Win32
    WinSock is built to be as compatible with the Unix sockets as possible, so even if the underlying implementation is different, the usage should be the same in almost every way.

    >>WinSock seems alot more complicated than how I use it back in VB...
    So is just about everything. Suck it up and start learning Really, once you've written a wrapper class for Winsock in C++, it's quite easy to use - even more so than the VB winsock control (I hated the blasted thing... ended up doing my project in C++ instead ).
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  13. #13
    Registered User
    Join Date
    Aug 2001
    Posts
    47
    Here's something to get you started .... I know I had some tutorial on the net regarding this subject, but I don't seem to remember were I found them......

    PHP Code:
    void CClient003Dlg::OnBnClickedButton1()
     {
        
    WORD sockVersion;
        
    WSADATA wsaData;

        
    sockVersion MAKEWORD(20);            // We'd like Winsock version 1.1
        
    WSAStartup(sockVersion, &wsaData);              // We begin by initializing Winsock
      
    SOCKET My_Socket socket(AF_INET,              // Go over TCP/IP
                                
    SOCK_STREAM,          // This is a stream-oriented socket
                                
    IPPROTO_TCP);         // Use TCP rather than UDP

      
    sockaddr_in My_Client;               // Use a SOCKADDR_IN to fill Address info.
        
      //%%%%%%%%%%%%%%//   
      // Client Part  //
      //%%%%%%%%%%%%%%//   
        
    My_Client.sin_family=AF_INET;
        
    My_Client.sin_port=htons(2000);
        
    My_Client.sin_addr.s_addr=inet_addr("127.0.0.1");
        if(
    connect(My_Socket,(LPSOCKADDR) &My_Client,sizeof(My_Client))==SOCKET_ERROR)
        {
            
    WSACleanup();
            
    closesocket(My_Socket);
            return;
        }

        
    char *msg "Ola Daniel";                            // Message to be sent
        
    int lenbytes_sent;
        
    len 80;                                            // Maximum number of bytes to send :-)
        
    bytes_sent send(My_Socketmsglen0);
      } 
    I'm a person with a simple taste...
    I only like the best.

  14. #14
    Chess Master Phanster's Avatar
    Join Date
    Oct 2004
    Posts
    8
    Thanks for that link DeepFrye, that site really helps.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting 32 bit binary IP to decimal IP (vice-versa)
    By Mankthetank19 in forum C Programming
    Replies: 15
    Last Post: 12-28-2009, 07:17 PM
  2. Replies: 6
    Last Post: 06-08-2006, 04:11 PM
  3. resolving names and ip addresses
    By dicky in forum Networking/Device Communication
    Replies: 5
    Last Post: 07-01-2004, 03:32 PM
  4. IP without connecting to external socket
    By Hunter2 in forum Networking/Device Communication
    Replies: 5
    Last Post: 08-26-2003, 07:50 AM