1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| //============================================================================
// Name : udp_client.cpp
// Author : Lange Olivier
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <netdb.h>
#include <netinet/in.h>
#include <unistd.h>
#include <iostream>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include "protocol.pb.h"
#include <string>
#include <cstring>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#define MAX_LINE 100
// 3 caractères pour les codes ASCII 'cr', 'lf' et '\0'
#define LINE_ARRAY_SIZE (MAX_LINE+3)
#define CLIENT_PORT 9096
#define CLIENT_IP "172.20.1.130"
#define SERVER_PORT 9096
#define SERVER_IP "172.20.1.103"
using namespace std;
int binToHexa (string data){
string returnData;
char *a=new char[data.size()+1];
a[data.size()]=0;
memcpy(a,data.c_str(),data.size());
int j = data.size();
for (int i=0; i<j; i++)
printf("%x ", a[i]);
return 0;
}
int Sock_SetBlockMode (int sock, bool blocking)
{
int flags;
int r;
flags = fcntl (sock, F_GETFL);
if (blocking == true)
r = fcntl (sock, F_SETFL, flags & ~O_NONBLOCK);
else
r = fcntl (sock, F_SETFL, flags | O_NONBLOCK);
return r;
}
int main()
{
//GOOGLE_PROTOBUF_VERIFY_VERSION;
//test::Error_Info test_msg;
test::Tube_Info test_msg;
/*
test_msg.set_from(1);
test_msg.set_to(2);
test_msg.set_msg("toto");
"udp_client.cpp" 178L, 4066C
[...] |
Partager