Mirage Source

Free ORPG making software.
It is currently Fri Mar 29, 2024 10:35 am

All times are UTC




Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: SOX instead of Winsock
PostPosted: Wed Dec 20, 2006 8:11 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Server Side:

-Delete the mswinsock control from the project

-Delete it from the control list too

-Add the sox.ocx

-Name it Socket

<!--[if !supportEmptyParas]--> <!--[endif]-->

frmServer.frm:

<!--[if !supportEmptyParas]--> <!--[endif]-->

delete or comment out the code you have for the old socket,

Socket_Accept

Socket_DataArrival

Socket_Close

<!--[if !supportEmptyParas]--> <!--[endif]-->

Now make a new Socket_State sub(go to the topleft combo box thing in the code window and select socket)

<!--[if !supportEmptyParas]--> <!--[endif]-->

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

<!--[if !supportEmptyParas]-->
Code:
<!--[endif]-->

Private Sub Socket_State(ByVal Sox As Long, ByVal State As Long)

    If Sox <> 0 Then 'not the main listening socket

        Select Case State

             Case 3

                 Call AcceptConnection(Sox)

             Case 0

                 Call CloseSocket(Sox)

        End Select

    End If   

End Sub

<!--[if !supportEmptyParas]-->
<!--[endif]-->

That should make sense now.

Now make a new DataArrival procedure.

<!--[if !supportEmptyParas]--> <!--[endif]-->

Private Sub Socket_DataArrival(ByVal Sox As Long, Data As Variant)

<!--[if !supportEmptyParas]--> <!--[endif]-->

End Sub

<!--[if !supportEmptyParas]--> <!--[endif]-->

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



Next add

<!--[if !supportEmptyParas]--> <!--[endif]-->

Call IncomingData(Sox, data)

End If

<!--[if !supportEmptyParas]--> <!--[endif]-->

You will change the incomingdata sub later

<!--[if !supportEmptyParas]--> <!--[endif]-->

It should end up looking like this..

Code:


Private Sub Socket_DataArrival(ByVal Sox As Long, Data As Variant)

    If IsConnected(Sox) Then

        Call IncomingData(Sox, Data)

    End If

End Sub

<!--[if !supportEmptyParas]--> <!--[endif]-->

Private Sub Socket_Error(Sox As Long, Proc As String, Area As String, Code As Long, Abbr As String, Desc As String, DescEx As String)

    'MsgBox "*** Error ***" & vbCrLf & vbTab & "Sox: " & Sox & vbCrLf & vbTab & "Proc: " & Proc & vbCrLf & vbTab & "Area: " & Area & vbCrLf & vbTab & "Code: " & Code & vbCrLf & vbTab & "Abbr: " & Abbr & vbCrLf & vbTab & "Desc: " & Desc & vbCrLf & vbTab & "DescEx: " & DescEx & vbCrLf & vbCrLf

End Sub


If you want you can add that, don’t need to, I commented it out on mine.

<!--[if !supportEmptyParas]--> <!--[endif]-->

Next: Incoming Data Sub

Change the header to look like this

Sub IncomingData(ByVal Index As Long, ByVal Data As Variant)

<!--[if !supportEmptyParas]--> <!--[endif]-->

Comment out or delete this:

'frmServer.Socket(Index).GetData Buffer, vbString, DataLength

<!--[if !supportEmptyParas]--> <!--[endif]-->

Add this, it converts the data to a string

Buffer = StrConv(Data, vbUnicode)

<!--[if !supportEmptyParas]--> <!--[endif]-->

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)




<!--[endif]-->

Next go to the AcceptConnection sub

<!--[if !supportEmptyParas]-->
Code:
<!--[endif]-->
Sub AcceptConnection(ByVal Index As Long)

Dim i As Long

<!--[if !supportEmptyParas]--> <!--[endif]-->

    If (Index = 0) Then

        i = FindOpenPlayerSlot

       

        If i <> 0 Then

             ' Whoho, we can connect them

             Call SocketConnected(Index)

<!--[if !supportEmptyParas]--> <!--[endif]-->

        Else

             frmServer.Socket.Close (Index)

        End If

    End If

End Sub


Make it like that

<!--[if !supportEmptyParas]--> <!--[endif]-->

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.

<!--[if !supportEmptyParas]--> <!--[endif]-->

Change Function GetPlayerIP to

Code:
 
Function GetPlayerIP(ByVal Index As Long) As String

    GetPlayerIP = frmServer.Socket.RemoteHostIP(Index)

End Function


Find ' Get the listening socket ready to go

Comment out both of the 2 lines under it which set the remotehost/port

<!--[if !supportEmptyParas]--> <!--[endif]-->

Comment/delete were it loads/unloads the sockets, you don’t need to do that anymore, its done internally.

<!--[if !supportEmptyParas]--> <!--[endif]-->

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)

<!--[if !supportEmptyParas]--> <!--[endif]-->Go to Sub ServerLogic

Get rid of that forloop which checks to see if it should close the socket

<!--[if !supportEmptyParas]--> <!--[endif]-->

Go to Sub UpdateCaption

Change it how you want, figure it out.

<!--[if !supportEmptyParas]--><!--[endif]--> Go to Function IsConnected

Add

Code:
If Index >= frmServer.Socket.Count Then

        IsConnected = False

        Exit Function

    End If


This is to avoid an error if it checks a socket which isn’t there.

Code:
 
If frmServer.Socket.State(Index) = 3 Then

        IsConnected = True

    Else

        IsConnected = False

    End If


Now change the other if statement to this…

<!--[if !supportEmptyParas]--> <!--[endif]-->

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

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 9:17 pm 
Offline
Pro
User avatar

Joined: Wed Sep 20, 2006 1:06 pm
Posts: 368
Location: UK
Google Talk: steve.bluez@googlemail.com
SOX vs. IOCP?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 9:18 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
IOCP wins since SOX is pretty much like winsock, just easier to use if I got it right in my memory.

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 9:26 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
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.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 10:10 pm 
Offline
Pro

Joined: Mon May 29, 2006 2:15 am
Posts: 368
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 :( [/code]

_________________
Image
Image
The quality of a man is not measured by how well he treats the knowledgeable and competent, but rather how he treats those less fortunate than himself.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 21, 2006 12:00 am 
Offline
Regular

Joined: Fri Dec 01, 2006 12:33 am
Posts: 37
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 21, 2006 1:15 am 
Offline
Pro

Joined: Sat Jun 03, 2006 8:32 pm
Posts: 415
I added IOCP fine before but I never tested it with people getting on and so on... so I dont know from that end.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 22, 2006 11:35 am 
Offline
Regular

Joined: Fri Dec 01, 2006 12:33 am
Posts: 37
Lol trust me... Its a nightmare all on its own.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 22, 2006 6:59 pm 
Offline
Pro

Joined: Mon May 29, 2006 2:15 am
Posts: 368
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...

_________________
Image
Image
The quality of a man is not measured by how well he treats the knowledgeable and competent, but rather how he treats those less fortunate than himself.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 03, 2007 2:30 am 
Offline
Newbie

Joined: Tue May 30, 2006 10:04 pm
Posts: 4
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?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 03, 2007 2:33 am 
Offline
Pro

Joined: Mon May 29, 2006 2:58 pm
Posts: 370
SOX is better ebcause its nicer.

the hacks make the capabilities better to.

it also supports pre-NT machines, IOCP does not.

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 03, 2007 3:14 am 
Offline
Pro

Joined: Mon May 29, 2006 1:40 pm
Posts: 430
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 03, 2007 6:47 am 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
SOX is built to be almost exactly like Winsock but easier - learn the controls and give a try. :wink:

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 25, 2007 9:26 am 
Offline
Regular
User avatar

Joined: Sat Feb 10, 2007 10:52 pm
Posts: 49
Location: Melbs Australia
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

_________________
Image
______________________________________________________________________________
www.animephantom.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 12:15 am 
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


Top
  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 2:50 am 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Bakekitsune wrote:
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


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.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 3:40 am 
well make a good copy/paste tutorial on how to add it into Mirage and we're all good Spodi :D


Top
  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 4:05 am 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Well it should be the same as adding SOX, but instead of a control its a module. :wink:

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 4:09 am 
Offline
Persistant Poster
User avatar

Joined: Wed Nov 29, 2006 11:25 pm
Posts: 860
Location: Ayer
Why did you name your engine vbgore?

Isn't gore an object and action as well?

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 4:42 am 
Offline
Regular

Joined: Tue Jun 13, 2006 4:46 am
Posts: 34
Kuja wrote:
Why did you name your engine vbgore?

Isn't gore an object and action as well?

It stands for something :)

Visual Basic Graphical(?) Online RPG Engine

_________________
http://www.createammorpg.com - Resources for making your online games
http://www.vbgore.com - vbGORE - Revolutionizing VB ORPG Development


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 7:37 am 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Nexarcon wrote:
Kuja wrote:
Why did you name your engine vbgore?

Isn't gore an object and action as well?

It stands for something :)

Visual Basic Graphical(?) Online RPG Engine


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:

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 10:59 pm 
thats also why I used Eloric :D

But if you can PM me info on how to add that socket i'll be happy spodi :D


Top
  
 
PostPosted: Tue Nov 02, 2021 9:34 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Brun259.3BettCHAPCafeMatiPetiBernFestPaulRhemPrimNouvCherPensTefaTescOpalTescXIIIZoneProsAtla
TescMarlElseSonyWindStVaVinoFierComeGlisLiesFrenNeoMPlanPureXVIIRobeGreeFranCurtBeteSileMary
BrauPhilTracAmarNaviVoguMechMariKoffsilvAcrySelaHuguPeriRobeXVIIYangthisJuleSelaQueeLiveXVII
AgatCondXVIIwwwlRobbBlacKoffZoneAutoParaItalGilbStopWackZonePePeRockLascRondZoneHoriJackZone
ZoneZoneSwarCarrRondZoneLobsCareZoneJohnZoneZoneSupeZoneMORGZoneWelcElisZoneSideCryiMaurBeno
ZoneAaviFranCMOSTeveArdoMielsameBookVasiTologateFierOlmeLeifDaviMRQiParkHyunRogeCurtSIRDFolk
LADYEditTrefMagiThisPuppWindSlimMicrwwwnMagnsupeBookVeryPlanAllaTemuAlfrDavisurrVelvElizTake
GorgWolfXVIIRichJacqTaylprosAlanContRetuGaliRussZombCaroADHDJeweMORGThisAlexWorlEricGoldAmwa
BriaGeorJudiKurtBoroKeeyBeauBrunHaleTobyVIIIAdobCharBeenMachJuneAmerWhitAdobAntoMicrCMOSCMOS
CMOSWITCPROMTonySUSEGreaMeatStopMariNeilCambMangThistuchkasCohePrel


Top
 Profile  
 
PostPosted: Fri Feb 18, 2022 2:54 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Econ250.1BettCHAPMillReflVisiJohnHoodCarlAlleDrinCurvEXPEWallElseMariShemTescRichZoneArthTesc
concXVIIWallCarlHansMipaHardJeuxWhenGillMicrCrosJameMineCaudIntrPublCredMaxtMelaJewePrelStra
RicaJohaUsedJeweGemiPushWindAdioGiorblacblacOsirStepJameMarkXIIIBernNeriStanTradVashConcAgat
GreeWindcartJeweHypnChamTranStepGustPanzGeorTotaArmyAlonZoneSkinKnocAladRondZoneLostRichZone
diamZoneZoneWorlJacoZoneXVIILaurZonenethZoneZoneSonjZoneZoneHughAlanExpeZoneWindZoneBonuMicr
ZonePalaPontNTSCKronSeleNordWongAmazFinaPostBookdesiThisMilaXVIIHeddPierCathCathComphtmlFolk
BALIMagiTrefBreaProjTranWindWindMicrSallBricDeLoSwarChouWhisJeweAnimloveGhosInsiRoyaAlaiInti
JeanNeveRadmDIDOCondWindCurrAutoRudyArouYossGaliMumiMargmailRockFoxCAlasTracPinkFrieHaryLego
JeanLeslRichEspaBuddLenkClaswwwrCapoAshefranHousYourTimoCastFredVIIIOwenSecrVIIITeriNTSCNTSC
NTSCMarkEverZitaCoreBrucGaryKingNeilBetsAlexexceTaketuchkasKnyrMoon


Top
 Profile  
 
PostPosted: Wed Mar 16, 2022 12:44 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatorhttp://magnetotelluricfield.rumailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffusersemiasphalticfluxsemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchucktaskreasoningtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimatetemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group