Perl Socket Client for C++ Server

2005-04-05 Thread news-funsi
Hi there,

i have written a socket c++ server, which listens for clients and
understands   some commands. 
here the structs of the server commands:


enum command { SET_PRIO, CLEAR, SEND_STRING, SET_CURSOR, SHOW_CURSOR };

struct string_packet_t
{
  char str[DATA_LENGTH];
};

struct int_packet_t
{
  int data;
};

 
struct cmd_packet_t
{
  command type; 
  union
  {
int_packet_t int_pkg;
string_packet_t str_pkg;
  };
};

a c++ client would now send following command over the socket to the the
server:

  cmd_packet_t command;
  command.type=SEND_STRING;
  strcpy(command.str_pkg.str, "Hello World");
  write(fd, &command, sizeof(command);

with c/c++ all is working fine. 

The problem is the perl client. after setting up the socket i tried:

print SOCKET sprintf(%u%d, 0, 2)
# 0 For the first command == SET_PRIO, 2 for the argument
but the server receives no useable data.
("12848" for the command value, instead of 0 and
 "1" for the integer argument)

any idea?

thank,

Simon Funke

-- 
Sparen beginnt mit GMX DSL: http://www.gmx.net/de/go/dsl

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Perl Socket Client for C++ Server

2005-04-06 Thread news-funsi
thanks zentara for the answer, but unfortunately this does not work.

I've uploaded the the C++ server/client and the testclient for perl.

after unpacking and compiling the fundaemon, the server executable is
src/fundaemon, which will create a file called /tmp/fundaemon_socket and
listens for clients. 
the c++ testclient is called "testclient", and has a small menu to control
the server.

C++ Server and Client
www.honktown.de/funk/fundaemon.tar.bz2


Perl Client:
http://www.honktown.de/funk/fundaemon_client.pm

greetings,

Simon Funke

-- 
Handyrechnung zu hoch? Tipp: SMS und MMS mit GMX
Seien Sie so frei: Alle Infos unter http://www.gmx.net/de/go/freesms

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Perl Socket Client for C++ Server

2005-04-07 Thread news-funsi
Hi Jay,

thanks for the answer. 

> Firt things first.  Why did you comment out use strict?  That's never
> a good sign.  also, loading both IO::Socket::Unix and Socket probably
> isn't the best idea.  the main problem here, though would seem to be
> mixing your syntax.  You're calling the object-oriented IO::Socket
> interface, but you're using it like you would the builtin functions. 
> You're also using incorect argument names.  
Your right. It was a dirty hack, and because it did not work with
IO::Socket::Unix, i tried the Socket library.

i'm playing with your version
(http://www.honktown.de/funk/fundaemon_client.pm), but i have the same
problem as before :(

Simon Funke


-- 
Sparen beginnt mit GMX DSL: http://www.gmx.net/de/go/dsl

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]