From: Michael Conrad Date: 2008-04-03T06:22:25+09:00 Subject: Socket::Constants incomplete ? --------------040801010507060505080409 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, today I tried to use ruby to read data from an ax25 socket using the socket api. I think, that some definitions/constants are missing. There are no constants for AF_AX25, AF_PACKET and the method htons is missing also. I have attached two (ugly, undocumented, unportable ;-) files, one containing a small c example, the other the correspoding ruby code. Output of listen.c af_packet: 17, sock_packet: 10, htons( AX25): 512 received: 101 bytes � � h � ` r ` � � ` � � � � � � ` � � @ ` � � � � b @ ` � � ` � � @ � � � � � d @ c  � = 4 9 3 2 . 2 3 N / 0 0 8 2 2 . 7 0 E _ . . . / . . . g . . . t 0 4 9 r 0 0 0 p 0 0 0 R 0 0 0 h 5 6 b 1 0 2 3 0 Output of listen.rb socket: # received: 101 bytes � � h � ` r ` � � ` � � � � � � ` � � @ ` � � � � b @ ` � � ` � � @ � � � � � d @ c  � = 4 9 3 2 . 2 3 N / 0 0 8 2 2 . 7 0 E _ . . . / . . . g . . . t 0 4 9 r 0 0 0 p 0 0 0 R 0 0 0 h 5 6 b 1 0 2 3 0 Is the incomplete ruby socket api a bug or do I have make something wrong ? My dpkg (debian packet tool) says ii ruby1.8 1.8.6.114-2 Interpreter of object-oriented scripting lan Regards Michael Conrad --------------040801010507060505080409 Content-Type: text/x-csrc; name="listen.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="listen.c" #include #include #include int main( int argc, char **argv) { int i; int sock; int size; unsigned char buffer[1500]; struct sockaddr sa; int sa_size = sizeof( sa); sock = socket( AF_PACKET, SOCK_PACKET, htons( ETH_P_AX25)); printf( "af_packet: %i, sock_packet: %i, htons( AX25): %i\n", AF_PACKET, SOCK_PACKET, htons( ETH_P_AX25)); size = recvfrom( sock, buffer, sizeof( buffer), 0, &sa, &sa_size); printf( "received: %i bytes\n", size); for( i=0; i