![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 234
Rep Power: 3
![]() |
Re: Simple BSD Sockets Problem
I managed to accept everything an IRC server has to say to me. This is my code:
c Syntax (Toggle Plain Text)
And this is What I get: You got the connection to the server! After send, entering recv loop Received: NOTICE AUTH :*** Processing connection to efnet.teleglobe.net Received: NOTICE AUTH :*** Looking up your hostname... NOTICE AUTH :*** Checking Ident NOTICE AUTH :*** Found your hostname Received: NOTICE AUTH :*** No Ident response Received: ERROR :Closing Link: 127.0.0.1 (Connection timed out) Received: Received: The error about "no ident response" comes up after waiting a few seconds. I am behind a router, but I have port forwarded the port 113 (which is used for ident) but with no effect whatsoever.
__________________
Project::Soulstorm (personal homepage) |
|
|
|
|
|
#12 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
Re: Simple BSD Sockets Problem
Usually that happens when you haven't sent the correct message, you haven't properly terminated the message, or you haven't sent a message when it was expecting one. My gut feeling is with the latter. During the time it's waiting, it could be waiting for you to send a valid reply or acknowledgement. I have no experience with interfacing to an IRC server, so I can't suggest anything specific.
Edit: I'm fairly confident with my assumption. NOTICE AUTH :*** No Ident response. It seems as though it was waiting for a response. Presumably, imformation about your identity. But you don't appear to send it anything. Consequently, it waits a few seconds, and then assumes you timed out and closes the connection. That is my assumption.
__________________
Waterloo's Canadian Computing Competition (CCC) - Stage 2 Problems, Solutions, and Test Data Last edited by Sane; Mar 4th, 2008 at 12:38 PM. |
|
|
|
|
|
#13 | |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 234
Rep Power: 3
![]() |
Re: Simple BSD Sockets Problem
Quote:
telnet efnet.teleglobe.net 6667 NICK NICK MyWayCoolBotNick\r\n USER ObjcBot 8 * :The Objective-C Bot\r\n I manages to connect and receive information about the server. However, I did that using the terminal. I don't know how can I send that using C. The only thing I manage to do is to open a telnet communication with the server with the connect() command. How can I send the other 2 commands? With the send() command? That's what I am trying in the code below. c Syntax (Toggle Plain Text)
But the problem is that it is as if those last 2 commands were never sent. Any ideas?
__________________
Project::Soulstorm (personal homepage) |
|
|
|
|
|
|
#14 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
Re: Simple BSD Sockets Problem
All telnet does is give you a direct TCP connection to the given server on the given port. You can then type out which characters you want to send and hit enter. It then reads back whatever it gets sent and writes it to screen.
What you really should do is write a both a client and a sever TCP program and run them together. Then you will get a firmer grasp of how to use send and recv properly. Also you aren't checking the returns of send, you should always check the return value.
__________________
Robotics @ Maryland AUV Team - Software Lead |
|
|
|
|
|
#15 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 234
Rep Power: 3
![]() |
Re: Simple BSD Sockets Problem
OK. I will write this dumb server.
However, I got it to work. Seems that if I give the NICK and USER command together with one send(), they will work. Otherwise, they won't. However, the strange thing is that in both cases, the return value of the send() command is 0! I really can't understand this. I will try and write the dumb server to see what will happen. c Syntax (Toggle Plain Text)
__________________
Project::Soulstorm (personal homepage) |
|
|
|
|
|
#16 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 816
Rep Power: 4
![]() |
Re: Simple BSD Sockets Problem
Your separate commands send the USER command then the NICK command, but your all in one sends NICK then USER. I don't know if that would cause the problem, but it would be worth checking out.
Also I would be tempted to use sizeof(userCommand) - 1 as the length to send, otherwise you are sending an extra zero byte which might be confusing the other end. |
|
|
|
|
|
#17 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 234
Rep Power: 3
![]() |
Re: Simple BSD Sockets Problem
You got me. The last character of the commands was the problem. I deleted the last character, and everything else worked fine. Thanks a lot.
__________________
Project::Soulstorm (personal homepage) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple blackjack script problem. Need help. | jokr004 | C++ | 6 | Feb 10th, 2006 11:44 AM |
| EXTREMELY simple problem | d_heyzie | C++ | 15 | Feb 2nd, 2006 11:32 PM |
| sockets, problem with select() | Wizard1988 | C++ | 0 | Jan 15th, 2006 4:09 PM |
| Simple Perl / MySQL Problem.. pls help! | domquemo | Perl | 0 | Jan 11th, 2006 4:08 AM |
| repaint() problem in very simple program | dotred | Java | 1 | Mar 17th, 2005 5:17 AM |