Non Blocking Socket
Non Blocking Socket
hi im searching idea to get a non blocking socket on linux i tryed with thread and
with http://www.lowtek.com/sockets/select.html
any suggestion are accepted =)
with http://www.lowtek.com/sockets/select.html
any suggestion are accepted =)
- ElvenProgrammer
- Founder
- Posts: 2526
- Joined: 13 Apr 2004, 19:11
- Location: Italy
- Contact:
You should try the new code. Ops I think it still has got some problems with the GUI, but just go straight on and you'll be fine (Genis what you've done to my GUI ). I just modified the first select parameter from 0 to 1. In win this is ignored but it isn't so in linux. I don't know if 1 is the correct value you should try also 2, 3, or sock.
If after that still doesn't work try adding again fcntl with O_NONBLOCKING flag after the creation of socket.
If still doesn't work, as someone suggested in #c irc channel, "Maybe you've a bad linux installation, but there's a solution: pack everyting in a box and go to your vendor and try to change that with a good WinXP"
I hope this can fix the problem. Ah remember Windows 12986E56 - Linux 0
If after that still doesn't work try adding again fcntl with O_NONBLOCKING flag after the creation of socket.
If still doesn't work, as someone suggested in #c irc channel, "Maybe you've a bad linux installation, but there's a solution: pack everyting in a box and go to your vendor and try to change that with a good WinXP"
I hope this can fix the problem. Ah remember Windows 12986E56 - Linux 0
If I ever get my laptop (linux) working again, I'll fix up the non-blocking sockets. I wont just write the code if I don't have a real enviornment to test it in, I always make stupid mistakes and it BUGS me :p
Ahh it will be nice to write c code for linux again, soo nice... I've been stuck in vb on windows for the last few months... *breaks out into tears* its soo horrible..
Anyway, hopefully I can help, but it will take a while for me to get this going, the laptop is... special, and I gotta install through a serial cable... So don't wait for me on this one ^_^
Oh yah - hi, I think I can help, and now its time to run
Ahh it will be nice to write c code for linux again, soo nice... I've been stuck in vb on windows for the last few months... *breaks out into tears* its soo horrible..
Anyway, hopefully I can help, but it will take a while for me to get this going, the laptop is... special, and I gotta install through a serial cable... So don't wait for me on this one ^_^
Oh yah - hi, I think I can help, and now its time to run
Socket problem fixed
Sull, get in irc. The socket is non-blocked now
It does not!
It does not you bozo! I just did it this is my second version. . . http://home.comcast.net/~cody_culter/tmw.tgz
omg
sorry, the link is http://home.comcast.net/~cody_cutler/tmw.tgz
ok, i tried the version u posted and compiled it. this is the output i get on stdout:
this is after i entered my account-data and clicked ok. bty, this is as far as it goes since tmw shuts itself down after the last line of the text stated above.
hope, this helps or anything...
Code: Select all
Socket created successfully. . .
Address resolved successfully. . .
Successfull connect . . .
sock file flags are 2
sock file flags are now 2050
Non-blocking socket created successfully (HAPPYDAY!)
Buffers initialized correctly. . .
session opened successfully!
Sending login info. . .
Login info sent successfully. . .
hope, this helps or anything...
Don't argue with idiots. They drag you down to their level and beat you with experience.
i played around a bit with your src cody.. same problem here
flush() sets "in_size" to -1 - Since it's not 0, the login() function continues (and tries to get the server-infos). after changing the line
while(in_size==0) flush();
to
while(in_size<=0) flush();
it works.. but it's an infinite loop. So i removed the select() and FD_ISSET()-things from flush(), (FD_ISSET returned false always) and it kinda worked.. but it sent no (or the wrong?) data.
eAthena notices a new connection, but no login packets.
maybe this will help somebody?
flush() sets "in_size" to -1 - Since it's not 0, the login() function continues (and tries to get the server-infos). after changing the line
while(in_size==0) flush();
to
while(in_size<=0) flush();
it works.. but it's an infinite loop. So i removed the select() and FD_ISSET()-things from flush(), (FD_ISSET returned false always) and it kinda worked.. but it sent no (or the wrong?) data.
eAthena notices a new connection, but no login packets.
maybe this will help somebody?
:> poor english i know ^^ hope you understood a half.. <:
________________________
asdf?!
come, lets talk with swords! omfg!
________________________
asdf?!
come, lets talk with swords! omfg!
Actually, it isn't bad not to use select(). . . select() is for file descriptor sets, and you can use non-blocking IO in two different ways. You can use fd_sets and select, or you can set your own file descriptor flags with fcntl. Since fd_sets used with select and socket file descriptor NEVER return true, (which is why it was in that infinite loop; FD_ISSET() checking whether to recv() never returned true) I had to use fcntl and a long, "sockflags". Also, I'm sorry guys, but before I made that tarball, I forgot to edit the "The Mana World.ini." If you haven't already, you've got to change the server and port to the correct stuff, I was using a local box. And I know that it exits after you click login. . . The point is that it doesn't get caught in an infinite loop anymore thanks to the non-blocking IO These bugs must also be worked out, so you can rest assured that someone will do it soon
update. . .
Ok, were getting close men! Instead of using my "save_file_flags" and "fcntl" to set our own file descriptor rules, I found out the problem with FD_SET and select() and the like. . . The select() function is called like this. . .
---------------------------------------------------------------------------
select(1, &read_socket, &write_socket, 0, &time_out);
---------------------------------------------------------------------------
it should be like this
---------------------------------------------------------------------------
select(sock + 1, &read_socket, &write_socket, 0, &time_out);
---------------------------------------------------------------------------
so get rid of the code changing the socket to nonblocking IO that I added above (with the "save_file_flags") and change select to like it above and the integration should be much more smooth. Take a look at my new code guys , I can tell that we are very, very close to getting a perfect Linux port of thus far. . .
---------------------------------------------------------------------------
select(1, &read_socket, &write_socket, 0, &time_out);
---------------------------------------------------------------------------
it should be like this
---------------------------------------------------------------------------
select(sock + 1, &read_socket, &write_socket, 0, &time_out);
---------------------------------------------------------------------------
so get rid of the code changing the socket to nonblocking IO that I added above (with the "save_file_flags") and change select to like it above and the integration should be much more smooth. Take a look at my new code guys , I can tell that we are very, very close to getting a perfect Linux port of thus far. . .
Guest: Oi.. dunno where to start.
Cody: Yay, you got it the select(1, ...) was checking from fd 0 to 1-1
... not very effective
World in general: Gah! Stupid fedora installer wont do a net install 'cause it cant recognize my PCMCIA ethernet adaptor! Next distro! (god, one of these has to support my laptop, I don't wanna have to do another custom "from scratch" build on it like I had to last time)
Cody: Yay, you got it the select(1, ...) was checking from fd 0 to 1-1
... not very effective
World in general: Gah! Stupid fedora installer wont do a net install 'cause it cant recognize my PCMCIA ethernet adaptor! Next distro! (god, one of these has to support my laptop, I don't wanna have to do another custom "from scratch" build on it like I had to last time)
Wohoo!
I got to try it out in Linux
Of course, there were problems but I could log in and see the character in-game and hear music
kth5 will probably give a better report. I was just happy =)
It now has the right tiles and I can WALK too (chat also )
I got to try it out in Linux
Of course, there were problems but I could log in and see the character in-game and hear music
kth5 will probably give a better report. I was just happy =)
It now has the right tiles and I can WALK too (chat also )
Quote of the year:
<Sull> the diff with GPL and priced software,GPL is faster to install cause you dont have to put a crack/serial
xD
<Sull> the diff with GPL and priced software,GPL is faster to install cause you dont have to put a crack/serial
xD