![]() |
SOX instead of Winsock - Printable Version +- Mirage Engine (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: SOX instead of Winsock (/showthread.php?tid=509) |
SOX instead of Winsock - William - 20-12-2006 Server Side: -Delete the mswinsock control from the project -Delete it from the control list too -Add the sox.ocx -Name it Socket frmServer.frm: delete or comment out the code you have for the old socket, Socket_Accept Socket_DataArrival Socket_Close Now make a new Socket_State sub(go to the topleft combo box thing in the code window and select socket) The state sub is called everytime the state of the socket changes 0 = close 1 = listening ‘server thing 2 = Connecting ‘Client thing 3 = Accepted ‘Server thing, Sox automatically accepts connections 4 = Connected ‘Client thing Code: Private Sub Socket_State(ByVal Sox As Long, ByVal State As Long) That should make sense now. Now make a new DataArrival procedure. Private Sub Socket_DataArrival(ByVal Sox As Long, Data As Variant) End Sub Inside add If IsConnected(Sox) Then ‘sox is the internal array index, no more control arrays, but you should know that if you read the readme ![]() Next add Call IncomingData(Sox, data) End If You will change the incomingdata sub later It should end up looking like this.. Code: Private Sub Socket_DataArrival(ByVal Sox As Long, Data As Variant) If you want you can add that, don’t need to, I commented it out on mine. Next: Incoming Data Sub Change the header to look like this Sub IncomingData(ByVal Index As Long, ByVal Data As Variant) Comment out or delete this: 'frmServer.Socket(Index).GetData Buffer, vbString, DataLength Add this, it converts the data to a string Buffer = StrConv(Data, vbUnicode) Scroll down in that sub and fine this: ' Check if elapsed time has passed Change the line below it to this: Code: Player(Index).DataBytes = Player(Index).DataBytes + UBound(Data) Next go to the AcceptConnection sub Code: Sub AcceptConnection(ByVal Index As Long) Make it like that In Sub CloseSocket Comment out where it closes the socket, kind of stupid making it close the socket since its getting called once the socket has closed. Change Function GetPlayerIP to Code: Function GetPlayerIP(ByVal Index As Long) As String Find ' Get the listening socket ready to go Comment out both of the 2 lines under it which set the remotehost/port Comment/delete were it loads/unloads the sockets, you don’t need to do that anymore, its done internally. Find frmServer.Socket.Listen -Change it to frmServer.Socket.Listen frmServer.Socket.RemoteHostIP(0), Game_port (might need to change it to 127.0.0.1, I’m not sure) Go to Sub ServerLogic Get rid of that forloop which checks to see if it should close the socket Go to Sub UpdateCaption Change it how you want, figure it out. Go to Function IsConnected Add Code: If Index >= frmServer.Socket.Count Then This is to avoid an error if it checks a socket which isn’t there. Code: If frmServer.Socket.State(Index) = 3 Then Now change the other if statement to this… Find .SendData (data here) Change it to frmserver.socket.sendstring i/index(depending where it is), data If you want to change this senddatatoall sub you can, you don’t have to though Go to sub senddatatoall Change it to frmServer.Socket.broadcast data - Xlithan - 20-12-2006 SOX vs. IOCP? - William - 20-12-2006 IOCP wins since SOX is pretty much like winsock, just easier to use if I got it right in my memory. - Spodi - 20-12-2006 SOX is just a nice wrapper for the Winsock API. Theres a few hacks you want to do on the socket itself to get it prepped for a game engine, though. For example, it sends a 4-byte (long) overhead for every SEND command, which is pretty useless for a game server (integer would suffice), the default send/recv buffer comes at 8192 bytes (you'd be fine lowering that to around 512 bytes easily), etc. And just a heads up, you cant use IOCP with SOX I believe, so you can't have an IOCP server and SOX client, because of the additional header I mentioned earlier. - Obsidian - 20-12-2006 Quote:And just a heads up, you cant use IOCP with SOX I believe, so you can't have an IOCP server and SOX client, because of the additional header I mentioned earlier. 'tis true ![]() - TheRealDamien - 21-12-2006 SOX in my personal opinion is a lot smoother/better... I have tried to add IOCP many times and guess what? Failure after failure... SOX is easy and in my personal opinion smoother and more stable. - halla - 21-12-2006 I added IOCP fine before but I never tested it with people getting on and so on... so I dont know from that end. - TheRealDamien - 22-12-2006 Lol trust me... Its a nightmare all on its own. - Obsidian - 22-12-2006 I've never had a problem with IOCP... this is a bit easier to add though... but i'm not sure how they compare as far as handling individual players.... but they're both probably far superior to the winsock control... - SoccerPeter - 03-01-2007 Don't take my word for it, because I don't know anything about SOX really, but someone told me a while ago that it can handle 6000 players easily provided they are on a good enough server machine. Is this true? - grimsk8ter11 - 03-01-2007 SOX is better ebcause its nicer. the hacks make the capabilities better to. it also supports pre-NT machines, IOCP does not. - Misunderstood - 03-01-2007 If anyone has a working sox client, please send it to me, I want to see if it works. I've been having trouble running MS via wine on linux, it works up to initializing TCP settings, which makes me think its a problem with winsock, I'm just curious if a sox client would work. - Spodi - 03-01-2007 SOX is built to be almost exactly like Winsock but easier - learn the controls and give a try. :wink: - Bakekitsune - 25-02-2007 hacks? also apparently you cant send binarydata with sox because of null. and were can you download the ocx? edit: dont worry i think im already using iocp lol - Boo - 12-04-2007 I was talking to nemesis and this is what he told me. On his testing when he used IOCP it used 70% of his CPU and when u used Sox it used only 30%. From this i concluded self explanitory that it'll be way faster to use Sox over IOCP unless your using a 3+ Dual Processor thats badass lol - Spodi - 12-04-2007 Bakekitsune Wrote:hacks? SOX handles data as variants by default, just like the winsock control. You can send as string or byte arrays. Quote:On his testing when he used IOCP it used 70% of his CPU and when u used Sox it used only 30%. SOX itself is pretty bloated as-is, and not really made well for games. You should try GOREsock from vbGORE - its a modified version of SOX directed towards faster handling. It takes out a lot of the overhead SOX has, like that extra 4 byte packet header added with every SendData call, plus easier handling for encrypting/decrypting packets. - Boo - 12-04-2007 well make a good copy/paste tutorial on how to add it into Mirage and we're all good Spodi ![]() - Spodi - 12-04-2007 Well it should be the same as adding SOX, but instead of a control its a module. :wink: - Tony - 12-04-2007 Why did you name your engine vbgore? Isn't gore an object and action as well? - Nexarcon - 12-04-2007 Kuja Wrote:Why did you name your engine vbgore?It stands for something ![]() Visual Basic Graphical(?) Online RPG Engine - Spodi - 12-04-2007 Nexarcon Wrote:Kuja Wrote:Why did you name your engine vbgore?It stands for something Exactly. A huge part of it was that I was trying to find something with very few results to Google so I can track the engine easier. You can type in "vbGORE" into google and most all results are towards my vbGORE. If you try that with Mirage, or Elysium... well, we all know. :wink: - Boo - 12-04-2007 thats also why I used Eloric ![]() But if you can PM me info on how to add that socket i'll be happy spodi ![]() |