Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Can't connect through ruby tcp

So... still aimlessly trying to get IRC working in RMXP is me.

The following script, I am assuming, should work:

Code:
begin

  @socket = TCPSocket.new("osprey.il.us.slacked.org", 6777)

  @socket.send("/NICK botbot")

  @socket.send("/USER botbotbot")

  @socket.send("/JOIN #clockwork")

end

I get the typical error everyone used to get when using Netplay, that is, "No connection could be made because the target machine actively refused it."

I have worked out that the error is on my end. The error occurs when the ip address used is not my machine.

It works if I use:

Code:
begin

  @socket = TCPSocket.new("127.0.0.1", 50000)

end

But does not work if I use

Code:
begin

  @socket = TCPSocket.new("82.47.xx.xxx", 50000)

end

I.e. localhost works, but not my external IP address.

This was a major problem with Netplay+ and as far as I can recall, nobody ever fixed it, hence the thousands of newbies giving up with the system and only a few people managing to get it to work.

I have since got a new PC which is why it isn't working now when it was before. But I have NO IDEA why it isn't working.

I have:
- AVG Antivirus

That is all :|
 
If you try to use your external IP address, then it is going to try to go through your router, which is probably not port forwarded on the port you are trying to access, so that is why the target machine would actively refuse that connection.

Before you decide that it is a problem with your code, why don't you see if you can make a connection to an IRC Server.

EDIT: Oh, ok, you were just using your ip as an example. Ok, well try connecting to irc.slacked.org and let it do the redirection to a specific server for you. I have successfully connected to an IRC server using the NetPlay sockets.

Also, try disabling your AV for a bit. AVG Free is a particularly bad example of an anti virus, and I know I had a lot of network troubles when I used to use it.
 
Disabling AVG hasn't helped :/. (Using both slacked and my own IP).

irc.slacked.org also doesn't work.

"No connection could be made because the target machine actively refused it."
 
Hmm, that's weird. Perhaps you set up the network scripts wrong.

Try this code here, I know for sure that it works:

Code:
 

class Scene_NetTest

  

  def main

    

    @socket = TCPSocket.new('irc.chatspike.net', 6667)

 

    while (@socket.ready? == 0)

 

      Graphics.update

 

    end

 

    print(@socket.recv(255))

 

  end

 

end    

 

Just put that as a scene above main and modify main to go to Scene_NetTest instead of the title.
 
Ah. That script works :)

Well, it says something along the lines of:

- checking your hostname
- checking your hostname
- checking your hostname
- checking your hostname
- no connection could be made as target machine refused it

(Which I am guessing is because the script didn't respond with a hostname).

I'm not sure what is different in your script to mine but it works :)
 
You're trying to send "/NICK" when the socket expects something else. Send "USER #{user_name} server #{server_name} :#{real_name}" then send "NICK #{nick_name}".
 
Actually, I think the target machine refused the connection this time because you didn't ping it. A lot of IRC servers require you to send "PING" (or is it PONG? I forget which the client is supposed to send) Try sending a "PING" or "PONG" after every recv.

@Yeyinde: I don't believe that would cause the connection to be refused, but I could be wrong. I think it wants to know that a proper client is connecting before it wants to know about a user.


@Wyatt: I think your script was not working because you were not asking the server for anything, you were just trying to send. I don't remember the exact process (I made an IRC bot in straight ruby before), but every server wants a two-way communication going on, and they usually like to be listened to first. Try googling Ruby IRC bot just so you can see what the flow of the code for an IRC Bot is. It's actually a bit more complex than you might think. You are going to have to explode the strings you receive and look at certain portions of the string to find out when you have to PING/PONG the server.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top