Thanks for your help, brandon!
I have figured out this socket index. It is like a number assigned for each socket. Like the index for an array.
However I am facing problems with CSocketPlus adding sockets into the socket array dynamically. Below is the flow of my logic (Not sure whether is it in the right direction, please advise.):
1) On Form Load
- Initialize a new socket array, CSocketPlus.
- Initialize global variable, intIndex, to 0.
- Initialize the first socket for listening.
Code:
Code:
Set client = New CSocketPlus
intIndex = 0
client.ArrayAdd (intIndex)
client.Bind intIndex, 9999, client.LocalIP(intIndex)
client.Listen (intIndex)
2) At Connection Request
- Close the requested socket.
- Initiate the connection with the socket.
- Increase the array socket count by 1.
- Add another socket into the array for listening.
Code:
Code:
client.CloseSck (Index)
client.Accept Index, requestID
intIndex = intIndex + 1
client.ArrayAdd (intIndex)
client.Bind intIndex, 2244, client.LocalIP(intIndex)
client.Listen (intIndex)
My problem occurs at the connection request. When my server is trying to connect back to the client, it will have an error: "Out of memory".
The only idea that I have in mind is that the array created is too small. Therefore unable to do an ArrayAdd.
I tried debugging and the IDE shows me that I am having an error while cleaning the array in the CSocketPlus class.
Below is the function that is having the error:
Please, would someone kindly point me to the correct direction for me to continue learning? Thanks!