Hi guys! I'm making my own Socket class(my private server development...) but i have one error on this:
char *HSocket::Recv()
{
char tmp[256*256];
int tmplen = 256*256;
int resize;
do{
resize = ::recv(this->socket,(char*)tmp,tmplen,0);
char *resized = new char[resize];
sprintf(resized,"%s",tmp);
delete [] tmp;
return resized;
}while(resize > 0);
};
But i didn't get all buffer, normaly i only get the first 20 or 15 char's... Why?
Hi guys! I'm making my own Socket class(my private server development...) but i have one error on this:
char *HSocket::Recv()
{
char tmp[256*256];
int tmplen = 256*256;
int resize;
do{
resize = ::recv(this->socket,(char*)tmp,tmplen,0);
char *resized = new char[resize];
sprintf(resized,"%s",tmp);
delete [] tmp;
return resized;
}while(resize > 0);
};
But i didn't get all buffer, normaly i only get the first 20 or 15 char's... Why?
You cannot delete[] a local array, it is used for dynamically allocated buffers.
I think boost::asio does a very good job at being a low level(!) modern written async network lib.
Its simply that asynchronous programming per se is a difficult and complex task.
Theres only one point about asio that bothers me: the lack of a good official tutorial. The documentation is very sporadic. Imho the examples are the best resource for learning boost::asio.
which suggested an tcp stream where you can shift in and out with << and >>. That would be nice.
I dont think thats even worth mentioning cause thats what every cpp-programmer should expect. Its a network _stream_ and therefore should support operator<</>>.
Imho cpp-netlib has a good attempt: (idk if its still maintained).
But i didn't get all buffer, normally i only get the first 20 or 15 char's... Why?
Show me your send function.send() might not send all the bytes as the kernel decided not to send all the data out in one pack.
maybe you can do it this way.
Quote:
int SendData(SOCKET socket, char *buffer, int *length)
{
int Total = 0;
int BytesLeft = *len;
int n;
while(Total < *length) {
n = send(s, buffer+Total, BytesLeft, 0);
if (n == -1) { break; }
Total += n;
BytesLeft -= n;
}
*length = Total;
return n == -1? -1 : 0;
}
And you can call the function like that.
Quote:
char buf[20] = "Send all data to ...";
int buflen = strlen(buf);
if((SendData(socket,buffer, &buflen) == -1)
{
//Failed to send all the data
cout << "Some data had n`t been sent:" << buflen << endl;
}
Take note :i am not sure if that is the matter i am just guessing.
Show me your send function.send() might not send all the bytes as the kernel decided not to send all the data out in one pack.
maybe you can do it this way.
And you can call the function like that.
Take note :i am not sure if that is the matter i am just guessing.
The client works perfectly, isn't coded by me(I'm developing p.server) ><
Port/Socket Error 01/11/2012 - CO2 Private Server - 4 Replies Alright, pretty sure this is the right place to post this.
I have decided to fool around with CO PServers as all I have ever coded and messed with is Java. I have touched a little bit into C# before but nothing major. But this is besides the point, actually I am fairly certain this has nothing to do with the coding of the server (oddly enough?).
Basically I have the ports 9958/5816 forwarded, added exceptions in firewall (inbound and outbound) and even tried cutting off the firewall, yet...
socket error W[200] L[........ 02/13/2011 - CrossFire - 4 Replies habe folgendes problem bei crossfire (habe keine hacks bots... auf mein pc)
habe windows7 32bit
und wenn ich crossfire im abgesiicherten modus installire dann
pc neu starte und starten will bleibt es bei der check box
auf 66% stehen und es kommt die oben genannte fehler meldung
wie kann ich das beheben ?
Socket Error? 07/29/2010 - S4 League - 8 Replies Everything is alright everything loads up.
Then this pops up!
Why is this happening and how do I fix it?
http://i285.photobucket.com/albums/ll54/animecraz ed598/S4leagueError2.jpg