2byte以上のデータ送信について
int 型のデータ4つを送信するためにプログラムを書いたのですがうまく動きません.
ご指摘ください.
送信側
ruby
1first = 0x00000001 2second = 0x00000000 3third = 0x00000000 4fourth = 0x00000000 5 6msg = [first,second,third,fourth].pack("N*") 7socket.write(msg) 8#これでネットワークバイトオーダでunsigned long * 4のデータサイズで書き込めるはず
受信側
C++
1 struct node *tmp; 2 if(recv(socket,tmp,sizeof(char) * 16,0) < 0) 3 perror("ID ERROR"); 4 tmp->n_ntoh(); 5//受け取ったデータをネットワークバイトオーダからホストオーダに変換して 6//値をとり出すことを目標 7 8 9//以下は他の部分でされている定義 10 typedef struct node { 11 uint32 first; 12 uint32 second; 13 uint32 third; 14 uint32 fourth; 15 void n_ntoh(void){ 16 first = ntoh(first); 17 second = ntoh(second); 18 third = ntoh(third); 19 fourth = ntoh(fourth); 20 } 21 };
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。