Non Blocking Socket

Ask for help regarding any technical issue or report any bug or OS independent issues.
User avatar
Sull
Novice
Novice
Posts: 163
Joined: 26 Apr 2004, 17:56
Location: Quebec,Montreal

Non Blocking Socket

Post by Sull » 06 Jul 2004, 02:58

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 =)
User avatar
ElvenProgrammer
TMW Adviser
TMW Adviser
Posts: 2526
Joined: 13 Apr 2004, 20:11
Location: Italy
Contact:

Post by ElvenProgrammer » 06 Jul 2004, 14:44

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 :cry: ). 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" :twisted:

I hope this can fix the problem. Ah remember Windows 12986E56 - Linux 0
User avatar
Genis
Peon
Peon
Posts: 82
Joined: 29 Apr 2004, 20:43
Contact:

Post by Genis » 06 Jul 2004, 15:12

what have I done to your gui?
nothing
Sorry...I only speak English
Ardaen
Peon
Peon
Posts: 24
Joined: 01 Jul 2004, 19:51

Post by Ardaen » 07 Jul 2004, 03:01

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
cody

Socket problem fixed

Post by cody » 16 Jul 2004, 04:29

Sull, get in irc. The socket is non-blocked now :D
User avatar
Shura
Peon
Peon
Posts: 96
Joined: 15 Jun 2004, 02:36

Post by Shura » 16 Jul 2004, 18:21

well it actually does not... it compiles cleanly but hangs while trying to send the given packet to the server at the login screen already...
cody

It does not!

Post by cody » 16 Jul 2004, 21:33

It does not you bozo! I just did it :) this is my second version. . . http://home.comcast.net/~cody_culter/tmw.tgz
cody

omg

Post by cody » 16 Jul 2004, 21:35

User avatar
Shura
Peon
Peon
Posts: 96
Joined: 15 Jun 2004, 02:36

Post by Shura » 17 Jul 2004, 14:11

ok, i tried the version u posted and compiled it. this is the output i get on stdout:

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. . .
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. :roll:

hope, this helps or anything...
Don't argue with idiots. They drag you down to their level and beat you with experience.
jui-feng
Peon
Peon
Posts: 26
Joined: 09 Jun 2004, 16:37

Post by jui-feng » 17 Jul 2004, 18:04

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?
:> poor english i know ^^ hope you understood a half.. <:

________________________
asdf?!
come, lets talk with swords! omfg!
Ardaen
Peon
Peon
Posts: 24
Joined: 01 Jul 2004, 19:51

Post by Ardaen » 17 Jul 2004, 19:37

No no bad bad bad!

A non blocking socket on linux without select is BAD. You'll kill your preformance!

Fine fine, since you all seem to get lost on this part I'll go finish installing linux on my laptop :p

Wish I never switched that laptop back to win 2k, that was a bad bad idea.
Guest

Post by Guest » 18 Jul 2004, 02:51

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 :D These bugs must also be worked out, so you can rest assured that someone will do it soon :D
cody

update. . .

Post by cody » 18 Jul 2004, 06:12

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 :D , I can tell that we are very, very close to getting a perfect Linux port of thus far. . .
Ardaen
Peon
Peon
Posts: 24
Joined: 01 Jul 2004, 19:51

Post by Ardaen » 18 Jul 2004, 08:09

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)
User avatar
Chetic
Peon
Peon
Posts: 63
Joined: 12 Jul 2004, 10:31
Location: Sweden
Contact:

Post by Chetic » 18 Jul 2004, 10:40

Wohoo!
I got to try it out in Linux :D
Of course, there were problems but I could log in and see the character in-game and hear music :P
kth5 will probably give a better report. I was just happy =)
Image
It now has the right tiles and I can WALK too :D (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
Post Reply