Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
Completed! Not Tested yet! But I think it works.
By: William
Difficulty: 3/5
Source: http://www.key2heaven.net/Socket2.rar
Thanks to Bhenur for the idea and explanation behind it.
Introduction
Backup your source!
Currently, the movement is handled through the same socket as everything else that sends from the client to the server. This tutorial will add two new sockets. One to the client and one to the server that handles the movement. So the sending delays decreases.
Client Side
Begin with adding a new socket to frmMirage. Name it "Socket2" without the quote tags.
Find:
Code: frmMirage.Socket.RemoteHost = GAME_IP
frmMirage.Socket.RemotePort = GAME_PORT
Below add:
Code: frmMirage.Socket2.RemoteHost = GAME_IP
frmMirage.Socket2.RemotePort = GAME_PORT2
Find:
Code: Sub TcpDestroy()
frmMirage.Socket.Close
Replace it with:
Code: Sub TcpDestroy()
frmMirage.Socket.Close
frmMirage.Socket2.Close
Under:
Code: Sub IncomingData(ByVal DataLength As Long)
Add this sub:
Code: Sub IncomingData2(ByVal DataLength As Long)
Dim Buffer As String
Dim Packet As String
Dim top As String * 3
Dim Start As Integer
frmMirage.Socket2.GetData Buffer, vbString, DataLength
PlayerBuffer = PlayerBuffer & Buffer
Start = InStr(PlayerBuffer, END_CHAR)
Do While Start > 0
Packet = Mid(PlayerBuffer, 1, Start - 1)
PlayerBuffer = Mid(PlayerBuffer, Start + 1, Len(PlayerBuffer))
Start = InStr(PlayerBuffer, END_CHAR)
If Len(Packet) > 0 Then
Call HandleData(Packet)
End If
Loop
End Sub
Under:
Code: Public Function ConnectToServer() As Boolean
Add:
[code]Public Function ConnectToServer2() As Boolean
'****************************************************************
'* WHEN WHO WHAT
'* ---- --- ----
'* 07/12/2005 Shannara Optimized function.
'****************************************************************
Dim Wait As Long
' Check to see if we are already connected, if so just exit
If IsConnected2 Then
ConnectToServer2 = True
Exit Function
End If
Wait = GetTickCount
With frmMirage.Socket2
.Close
.Connect
End With
' Wait until connected or 3 seconds have passed and report the server being down
Do While (Not IsConnected2) And (GetTickCount = Player(Index).DataTimer + 1000 Then
Player(Index).DataTimer = GetTickCount
Player(Index).DataBytes = 0
Player(Index).DataPackets = 0
Exit Sub
End If
' Check for data flooding
If Player(Index).DataBytes > 1000 And GetPlayerAccess(Index)
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
The tutorial is completed. This source has it added and works great: http://www.key2heaven.net/Socket2.rar
Feel free to test the tutorial and see if I remembered to put everything into it. Thanks
Hopefully someone who has some knowledge in this could say some words what this does so people will trust it
What exactly does it do? Just a separate socket for movement?
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
Yeah, instead of letting everything getting buffered and such in one socket. The new movement socket handles only movement and therefore decreases the delay and preassure on the main socket  I dont have so much knowledge in what benefits it has. But sounded like a good idea when bhenur told me about it. And that wow uses like 4-5 for it
Hopyfully Bhenur can explain some about it, since he recently read up on this kind of things.
From the reference:
Congestion control
The final part to TCP is congestion control. TCP uses a number of mechanisms to achieve high performance and avoid 'congestion collapse', where network performance can fall by several orders of magnitude. These mechanisms control the rate of data entering the network, keeping the data flow below a rate that would trigger collapse.
Acknowledgments for data sent, or lack of acknowledgments, are used by senders to implicitly interpret network conditions between the TCP sender and receiver. Coupled with timers, TCP senders and receivers can alter the behavior of the flow of data. This is more generally referred to as flow control, congestion control and/or network congestion avoidance.
Modern implementations of TCP contain four intertwined algorithms: Slow-start, congestion avoidance, fast retransmit, and fast recovery (RFC2581).
Enhancing TCP to reliably handle loss, minimize errors, manage congestion and go fast in very high-speed environments are ongoing areas of research and standards development.
I don't think i need to shed more light on this really, William did a decent job.
For a practical example check out the plugin for Firefox called DownThemAll at http://www.downthemall.net/. This plugin accelerates your downloads by breaking files into 5 parts - each on different TCP connections.
good job William well i like it allot, so I’m giving you a 10/10 and the right to use my particle system into a tutorial teaching hem how to use bitblt particle system. that’s if you want to. I would do it but as I told you I rather not because I don’t truly think they deserve stuff like that. But that’s up to you William I leave it in your hands.
genusis Wrote:good job William well i like it allot, so I’m giving you a 10/10 and the right to use my particle system into a tutorial teaching hem how to use bitblt particle system. that’s if you want to. I would do it but as I told you I rather not because I don’t truly think they deserve stuff like that. But that’s up to you William I leave it in your hands.
We don't deserve your system? We don't care about it. If it's using DX7 it's not a very good method anyways. If we wanted a good one, or one at all, we could convert MS to DX8 and borrow the system in vbGORE.
If you wanna talk about deserving something, you don't deserve to be here. We've all helped you enormous amounts of time. And you've asked me to join in several retarded projects. Like an OS made in VB..? Dude..
Anyways..
William, how much will this change? Is it really worth putting it in? I've yet to see much of a problem in my game, but that's also because it's not that popular yet so we don't have a lot of players on..
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
Genusis, you are our guest here and the way you a behaving is unacceptable.
Either step in line or get back to Elysium, where you belong.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Robin Wrote:Genusis, you are our guest here and the way you a behaving is unacceptable.
Either step in line or get back to Elysium, where you belong.
IVE BEEN HIDING IN ELYSIUM SHMUT ZOMG. Not.
I swear Will does a shitload but no one ever appreciates it.
Anyways, nice work.
how much does this affect speed and fps ? sounds like a great tutorial
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
frozen you really should read through a tutorial first.
This won't effect your FPS or speed at all, it is simply trying to relieve some of the main sockets stress by receiving the most common packets through a different socket.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
ah ok, thanks for the info
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
So Dave, your saying that the tutorial doesn't do much good? I was thinking that dividing it into 2 sockets would decrease a lot of preassure on the socket. And also smoothen the movement a tiny bit too since it can send a packet from both sockets at the exact same time.
Guys lets just be simple,
send 100 cars down a 1 lane road they are going to have to wait on each other a lil,
send 50 cars down a road each its going to make things easier and reduce waiting times,
its not that difficult...
Other online modern games use like 23874297482734 gazillion sockets, kinda seems stupid just to utilize one,
cant be a step backwards, it just cant; logic negates that
Fox Wrote:Guys lets just be simple,
send 100 cars down a 1 lane road they are going to have to wait on each other a lil,
send 50 cars down a road each its going to make things easier and reduce waiting times,
its not that difficult...
Other online modern games use like 23874297482734 gazillion sockets, kinda seems stupid just to utilize one,
cant be a step backwards, it just cant; logic negates that
I dunno much about winsock, or if what I'm about to say is even true, it's just a theory to combat what you said.
If the program only allows for one to be active at a time, then there is no point in having both. Know what I mean?
You can have more than one socket active at a time...
Dave Wrote:Send 100 cars down a one lane road when you can only send one car at a time. You get no speed bonus from adding more lanes.
You can only send one packet at a time (you can not call send() twice at the same time)
You can only receive one packet at a time (you can not call receive() twice at the same time)
Explain to me where the speed increase is?
So I was right then..?
why cant you handle multiple packets using different sockets?
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
Obviously the call senddata can't ran twice at the exact same time. But if you are running and typing at the same time, and you hit enter while running. The movement socket wont need to deal with the message being sent.
The movement socket is independent on all the other data being sent.
William Wrote:Obviously the call senddata can't ran twice at the exact same time. But if you are running and typing at the same time, and you hit enter while running. The movement socket wont need to deal with the message being sent.
The movement socket is independent on all the other data being sent.
It can still only send one thing at a time, so I don't see how it would make much of a difference..
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
It doesn't make much of a difference, but it do affect it a little. There is no downside by adding this. And unless you guys come up with a strong case why this wouldn't decrease the sending delay, I still think it's a decent thing that could be added.
William Wrote:It doesn't make much of a difference, but it do affect it a little. There is no downside by adding this. And unless you guys come up with a strong case why this wouldn't decrease the sending delay, I still think it's a decent thing that could be added.
If it can't call that sub more than once at the exact time, it's the same as one socket.
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
If you checked my tutorial, it doesn't use the same senddata sub, since senddata is linked to socket1, and my senddata2 sub is linked to socket2. This way both those subs can run at the same time.
Its just senddata that cant be run at the same time twice. But by having two subs for the sending, it can.
William Wrote:If you checked my tutorial, it doesn't use the same senddata sub, since senddata is linked to socket1, and my senddata2 sub is linked to socket2. This way both those subs can run at the same time.
Its just senddata that cant be run at the same time twice. But by having two subs for the sending, it can.
Ah, maybe.. I'll take a look at it later. Might be a good idea to split it up for all kinds of different things.
Posts: 2,605
Threads: 412
Joined: Nov 2021
Reputation:
0
You changed your opinion fast xD
When I talked to bhenur about this, he told me it wasn't really neccessary to add this for more than movement.
Another thing that would be great though would be to add a new socket for the chat, and setup a 2nd server for that. Even better would be to set that chat server at your friends house if you dont have a good connection.
|