IRC Bot Sockets Help

Post questions regarding programming in C/C++ in Linux/Unix.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

IRC Bot Sockets Help

Postby turdie » Sat Aug 29, 2009 1:43 am

hi :)
Last edited by turdie on Fri Sep 11, 2009 11:37 pm, edited 1 time in total.
turdie
 
Posts: 4
Joined: Sat Aug 29, 2009 1:35 am

Re: IRC Bot Sockets Help

Postby MXP » Mon Aug 31, 2009 2:02 pm

Beej's Guide to Network Programming describes how to set up and use sockets in a way which work on Windows and Linux. If you have specific errors or issues please describe them in more detail and we can work through those.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Re: IRC Bot Sockets Help

Postby turdie » Wed Sep 02, 2009 7:48 pm

hi :)
Last edited by turdie on Fri Sep 11, 2009 11:37 pm, edited 1 time in total.
turdie
 
Posts: 4
Joined: Sat Aug 29, 2009 1:35 am

Re: IRC Bot Sockets Help

Postby MXP » Thu Sep 03, 2009 2:16 pm

Beej's guide has lots of sample code including several full programs.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Re: IRC Bot Sockets Help

Postby turdie » Thu Sep 03, 2009 5:03 pm

hi :)
Last edited by turdie on Fri Sep 11, 2009 11:37 pm, edited 1 time in total.
turdie
 
Posts: 4
Joined: Sat Aug 29, 2009 1:35 am

Re: IRC Bot Sockets Help

Postby MXP » Thu Sep 03, 2009 6:09 pm

socket() creates the socket and connect() will allow you to connect to a specific IP and port, not unlike your Python example. Can you post your C++ code so we can see what is incorrect?
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Re: IRC Bot Sockets Help

Postby turdie » Fri Sep 04, 2009 8:11 am

hi :)
Last edited by turdie on Fri Sep 11, 2009 11:36 pm, edited 1 time in total.
turdie
 
Posts: 4
Joined: Sat Aug 29, 2009 1:35 am

Re: IRC Bot Sockets Help

Postby MXP » Fri Sep 04, 2009 11:59 am

Unlike in python, sock is not an object; sock is just a handle to the object and it must be passed as the first parameter to connect().
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Re: IRC Bot Sockets Help

Postby MXP » Wed Sep 09, 2009 2:49 pm

Please always post any errors you receive. It makes finding what the problem is easier.

The prototype for connect() is

Code: Select all
int connect(int sockfd, struct sockaddr *serv_addr, int addrlen);


You are passing a string in for the second parameter and a port number for the third parameter but this is not correct. The second parameter is a structure which has information about the address and port and the third parameter is the actual length of the address member of that structure. Generally you generate this structure using getaddrinfo() as you can see in this bit of example code.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm


Return to Unix/Linux

Who is online

Users browsing this forum: No registered users and 1 guest