|
You last visited: Today at 12:22
Advertisement
[Help]SocketConnection 5290+
Discussion on [Help]SocketConnection 5290+ within the CO2 Private Server forum part of the Conquer Online 2 category.
02/11/2011, 12:33
|
#1
|
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
|
[Help]SocketConnection 5290+
Code:
int main()
{
CRc5 dec;
WSADATA wsaData;
int err;
if((err =WSAStartup(0x0002, &wsaData)) !=0)
{
printf("Init WSAStartup() failed[%d].", err);
return false;
}
//socket structure
SOCKADDR_IN addr;//addr = socket structure
int addrlen = sizeof(addr);
//making the socket
SOCKET sListen;//listenig to the incoming connections
SOCKET sConnect;//operating the connection
//setuping the socket
sConnect=socket(AF_INET,SOCK_STREAM,NULL);//sock_stream = that the socket is a connection_oriented
//setup the structure
addr.sin_addr.s_addr=inet_addr("127.0.0.1");// ip of the connection
addr.sin_family= AF_INET;
//seting the prot
addr.sin_port= htons(9958);
//sertuping Listen socket
sListen=socket(AF_INET,SOCK_STREAM,NULL);
//binding connection
bind(sListen,(SOCKADDR*)&addr,sizeof(addr));
//listening
listen(sListen,SOMAXCONN);//listing with out any limit
printf("Attempting Socket Connection\n");
printf("Wating For An Incoming Connection!\n");
for(;;)
{
if((sConnect=accept(sListen,(SOCKADDR*)&addr,&addrlen)) != INVALID_SOCKET)
{
char buf[500];
int len = strlen(buf);
recv(sConnect,buf,len,0);
}
else
{
printf("Error accepting %d\n",WSAGetLastError());
}
}
}
but it's not receiving anything it's accepting the socket and then nothing happend why!!?
|
|
|
02/11/2011, 13:08
|
#2
|
elite*gold: 0
Join Date: Aug 2010
Posts: 991
Received Thanks: 1,107
|
Quote:
addr.sin_port= htons(9958);
|
i thought the port must be 9959 am i right ?
oh and btw take a look at this thread it might help you .
|
|
|
02/11/2011, 13:36
|
#3
|
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
|
Quote:
Originally Posted by { Angelius }
i thought the port must be 9959 am i right ?
oh and btw take a look at this thread it might help you .
|
yeah it's 9959 but am working with 9958 , Immunes is c# mine is c++
|
|
|
02/11/2011, 14:53
|
#4
|
elite*gold: 0
Join Date: Nov 2010
Posts: 159
Received Thanks: 39
|
Quote:
Originally Posted by Mr_PoP
yeah it's 9959 but am working with 9958 , Immunes is c# mine is c++
|
C# or c++ port should by 9959.
|
|
|
02/11/2011, 14:57
|
#5
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
|
The port can be whatever you want aslong as you remember to change the conquer.exe to suit the new port.
|
|
|
02/11/2011, 15:06
|
#6
|
elite*gold: 20
Join Date: Jan 2008
Posts: 1,042
Received Thanks: 252
|
Code:
int len = strlen(buf);
recv(sConnect,buf,len,0);
->
Code:
recv(sConnect, buf, 500, 0);
You've initialized a buffer of 500 bytes, but the string length is 0.
I have a kind of minor OCD complex with buffer sizes, and tend to always use multiples of 512
Nice to see abit more c++ here anyway.
|
|
|
02/11/2011, 15:10
|
#7
|
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
|
This is completely patch / conquer unrelated.
|
|
|
02/11/2011, 15:37
|
#8
|
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
|
Quote:
Originally Posted by S/W
C# or c++ port should by 9959.
|
Quote:
Originally Posted by Korvacs
The port can be whatever you want aslong as you remember to change the conquer.exe to suit the new port.
|
Exactly
Quote:
Originally Posted by © Haydz
Code:
int len = strlen(buf);
recv(sConnect,buf,len,0);
->
Code:
recv(sConnect, buf, 500, 0);
You've initialized a buffer of 500 bytes, but the string length is 0.
I have a kind of minor OCD complex with buffer sizes, and tend to always use multiples of 512
Nice to see abit more c++ here anyway.
|
i did wat u said but still it's not accepting to recv() <<< when it comes there it's like the program stop working but while am in infinity loop the program doesnot close , I appreciate ur help , please if there something else i missed or something i should add tell me thnx
Quote:
Originally Posted by Basser
This is completely patch / conquer unrelated.
|
what are u talking about?!
|
|
|
02/11/2011, 15:48
|
#9
|
elite*gold: 20
Join Date: Jan 2008
Posts: 1,042
Received Thanks: 252
|
Code:
WSAStartup(0x0002, &wsaData)) !=0)
Needs to be 0x202, instead of 0x0002.
Code:
sListen=socket(AF_INET,SOCK_STREAM,NULL);
Didn't even notice this but, it needs to be IPPROTO_TCP instead of null
Verified this for you on my side, and is working correctly.
|
|
|
02/11/2011, 16:02
|
#10
|
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
|
Quote:
Originally Posted by © Haydz
Code:
WSAStartup(0x0002, &wsaData)) !=0)
Needs to be 0x202, instead of 0x0002.
Code:
sListen=socket(AF_INET,SOCK_STREAM,NULL);
Didn't even notice this but, it needs to be IPPROTO_TCP instead of null
Verified this for you on my side, and is working correctly.
|
i did that and still it's not working look it works for (5017-5100+) but like 5200+ it's not , look try to test it on a Client patch 5295 u will see what am talking about
|
|
|
02/11/2011, 16:08
|
#11
|
elite*gold: 20
Join Date: Jan 2008
Posts: 1,042
Received Thanks: 252
|
Quote:
Originally Posted by Mr_PoP
i did that and still it's not working look it works for (5017-5100+) but like 5200+ it's not , look try to test it on a Client patch 5295 u will see what am talking about
|
Because on those later client's you send them the password seed, before they send you anything.
|
|
|
02/11/2011, 16:17
|
#12
|
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
|
Quote:
Originally Posted by © Haydz
Because on those later client's you send them the password seed, before they send you anything.
|
i know am being mean but can u give me an Exmaple if u dont mind
Edit: what do u think using C++/CLI (socket) better or the normal WinSock?
|
|
|
02/11/2011, 16:55
|
#13
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,377
|
I've posted the packet example in a bunch of different forums...
Recent patches use the new password encryption which requires a password seed. The client does not send any packets until it receives this packet.
It's only 8 bytes (length, type and then a random int pass seed)
|
|
|
02/11/2011, 16:57
|
#14
|
elite*gold: 0
Join Date: Nov 2009
Posts: 390
Received Thanks: 321
|
You can't mix C++/CLI code with native C++ code normally, and to do so you'd have to go through loads of code.
You can't use the current code to send a password seed packet either, you have to construct the packet and encrypt it with the auth crypto then send() it.
|
|
|
02/11/2011, 18:41
|
#15
|
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
|
Quote:
Originally Posted by Nullable
You can't mix C++/CLI code with native C++ code normally, and to do so you'd have to go through loads of code.
You can't use the current code to send a password seed packet either, you have to construct the packet and encrypt it with the auth crypto then send() it.
|
Or, since the auth crypto doesn't use a public key and it has just a 255 bytes which it uses to encode/decode buffers, you can simply calc it once, and just make a const buffer that needs to be sent.
|
|
|
Similar Threads
|
MessagePacket 5290
02/11/2011 - CO2 Private Server - 1 Replies
Problem Solved. Impulse FTW
Your structure is Wrong Basser.
|
5290
02/08/2011 - CO2 Private Server - 7 Replies
Problem solved, Thanks everybody.
#request close
|
Fix 5290+ source NPC option!!!!
09/18/2010 - CO2 PServer Guides & Releases - 1 Replies
First thx pro4ever rel this source !!!!
I set up , and test it ...
Test the npc option is not work...
now i will teach you how to fix that
Open SocketClient.cs
Add code:
|
where can i download 5290 c# Source
09/02/2010 - CO2 Private Server - 19 Replies
hello
I saw some people talking about the new 5290 C# Source.
if any one have it or know from where can i download Source.
Tell ME Please
(If it is full or not, there are my friends will be working In IT )
They Learned C# Language
Sorry For My Bad English:p
|
All times are GMT +2. The time now is 12:22.
|
|