Friday 13 March 2009

Client-Serever , Victory!

Success , I love this word!
Using http://tldp.org/LDP/LG/issue74/tougher.html , state from Linux gazette , I made working client-server system which answer Srop needs.

Now I will construct server and rewrite client using client-server system.

Monday 2 March 2009

Client-Serever problem

Working on client-server problem, i was defeated by problem(((
Using SDL_net i can send message to server, but can't get answer.
My trings end on this:
Server
//SROP serv test
#include
#include
#include "SDL_net.h"
#define MAXLEN 1024

main()
{
if( SDLNet_Init()==-1 ){
printf( "SDLNet_Init(): %s\n", SDLNet_GetError() );
exit( 2 );
}
IPaddress ip,*remote_ip;
TCPsocket tcpsock,new_tcpsock;
//Get request
if( SDLNet_ResolveHost( &ip, NULL, 8080 )==-1 ){
printf( "SDLNet_ResolveHost: %s\n", SDLNet_GetError() );
exit( 1 );
}
tcpsock=SDLNet_TCP_Open( &ip );
if( !tcpsock ){
printf( "SDLNet_TCP_Open: %s\n", SDLNet_GetError() );
exit( 2 );
}
do
new_tcpsock=SDLNet_TCP_Accept( tcpsock );
while( !new_tcpsock );

char message[ MAXLEN ];
if( SDLNet_TCP_Recv( new_tcpsock, message, MAXLEN )<=0 ) printf( "Error\n" ); remote_ip=SDLNet_TCP_GetPeerAddress( new_tcpsock ); if( !remote_ip ) { printf( "SDLNet_TCP_GetPeerAddress: %s\n", SDLNet_GetError() ); printf( "This may be a server socket.\n" ); } printf( "Host: %i\nPort: %i\nMessage:\n%s\n", remote_ip->host,remote_ip->port, message );
SDLNet_TCP_Close( tcpsock );
SDLNet_Quit();
}


Client
//SROP client test
#include
#include
#include "SDL_net.h"
#define MAXLEN 1024

main()
{
if( SDLNet_Init()==-1 ){
printf( "SDLNet_Init(): %s\n", SDLNet_GetError() );
exit( 2 );
}

IPaddress ip;
TCPsocket tcpsock;
int len;
char *msg="Hello!\n";
//Sending message
if( SDLNet_ResolveHost( &ip, "127.0.0.1", 8080 )==-1 ){
printf( "SDLNet_ResolveHost: %s\n", SDLNet_GetError() );
exit( 1 );
}
tcpsock=SDLNet_TCP_Open( &ip );
if( !tcpsock ){
printf( "SDLNet_TCP_Open: %s\n", SDLNet_GetError() );
exit( 2 );
}

len=strlen( msg )+1;
if( SDLNet_TCP_Send( tcpsock, msg, len )


Now I will try to made this using http://www.alhem.net/Sockets/

Sunday 1 March 2009

SROP project is open

Hi All
Now Srop project is open and I hope that it will never close :)
Srop will be a Bazaar project and anybody can develop it with me.
Srop page in google code is http://code.google.com/p/srop/ , there I will publish files and many other.

So, now I have a two giant questions:
1.Map of object(now ship is flying over islands)
and
2.Client-Server protocol using SDL-net (now I use function send_to_server() which emulate server answers...)

I must say, that to try Srop:
ID=0000
pass=3091

P.S.My English isn't good, so if I will do some mistakes please say me about them and I will try to be correct in future =)

And two images of srop )