[SOLVED] socket_listen && socket_open error
In one plugin i'm creating TCP listen socket on local 127.0.0.1 ip address. (port: 1337)
Also in that plugin i'm trying to create new socket via socket_open to send data on local port. Problem is that when i use socket_open for sending i get connection error. I tried using socket_open_non_blocking and then socket is created, data is sent, but listen socket doesn't receive anything. Here are the func: SEND Data: Code:
SendData( const sOne[ ], const sTwo[ ], iNum )Code:
|
Re: socket_listen && socket_open error
Edit: Nevermind, see Bugsy's post. |
Re: socket_listen && socket_open error
Did you just copy this and modify it?
|
Re: socket_listen && socket_open error
There shouldn't be a problem with listening on one socket and connecting\sending with a different socket on the same port, you just cannot have multiple sockets listening on the same port. I don't have time to test this for you but one thing I see is you should check socket_change() on the listening socket before calling socket_accept(); this indicates that there is a connection request. Take a look at the sockets_forwards in the .inc file, it might help you solve this. Did you add some logs\[clientserver\console]_print's to confirm the entity is thinking and each piece of code is getting reached?
|
Re: socket_listen && socket_open error
Quote:
Check this thread http://forums.alliedmods.net/showthread.php?t=80413 and answer me if you can :) I'm testing socket functions and transfering strings from one server to another server, but because i have only one server, i'm sending data to same ip/port on which is listening socket. Quote:
About socket_forward.inc, i checked almost "all socket codes" here, and noticed when using TCP socket, there is no need for socket_change check. I forgot to mention, before puting all this in one plugin, i used 2 plugins, one for reading, one for sending, and it worked like a charm. Server is hosted on linux platform, and i'm currently using socket_hz module, modified by joaquimandrade ( Link: Here ) EDIT: Solved, i made a small tipo, check first post ( listen func ) EDIT2: joaquimandrade socket_open_non_blocking doesn't return error on connection fail, i switched back to original socket_hz. |
Re: socket_listen && socket_open error
Quote:
What do you mean there is no need for a socket_change() check? socket_change() calls the select() function which determines if any activity (data-arrival, socket-writeability, connection request, remote party disconnect) has occurred on a given socket so you can then react to it accordingly. Please explain why this isn't needed, or shouldn't be used. |
Re: socket_listen && socket_open error
Quote:
About socket_change, i said that i noticed that it isn't used on TCP socket listen. I saw that from tutorials on this forum. You are probably right, but i haven't seen that anyone is using it in TCP socket. I'm relativly new to sockets, used them once/twice before and thats it. Examples which i found: https://forums.alliedmods.net/showpo...50&postcount=1 http://forums.alliedmods.net/showthread.php?t=150519 - api One more question :) I send strings which are not related to other strings which are also sent. Can i do this with UDP socket? Important thing is:
|
Re: socket_listen && socket_open error
I would stick with TCP:
TCP
|
Re: socket_listen && socket_open error
Thank you bugsy fo helping :)
|
| All times are GMT -4. The time now is 06:15. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.