-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmy_ip.h
More file actions
50 lines (48 loc) · 1.46 KB
/
my_ip.h
File metadata and controls
50 lines (48 loc) · 1.46 KB
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
/******************************************************************************
name : my_ip.h
date : 26 April 2015
created by : ldelaveau
last modified : 26 April 2015 09:51:43 PM
last changes by : ldelaveau
******************************************************************************/
#include<sys/socket.h>
#include<sys/types.h>
#include<arpa/inet.h>
#include<stdlib.h>
#include"my_stdio.h"
/*
* Socket struct addr initialized
*/
struct sockaddr_in my_sockaddr;
/*
* This function will try to open a connection the the host
* identified by the IP and the port given in "type" mode.
* Types:
* - 0: SOCK_STREAM (TCP, Default)
* - 1: SOCK_DGRAM (UDP)
* - 2: SOCK_SEQPACKET (see man 3 socket)
*
* param: char *IP adress, short port, int type
* return: int socketDescriptor if it success
* Instead, the function returns:
* -1 : Connection time out
* -2 : wrong username
* .
* .
* .
*/
int my_init_co(char *IP, short port, int type);
/*
* Send message in a packet by a opened socket.
* Others informations are stored in sockaddr_in structure defined
* in this file.
* param: int socket, char *msg (use struct sockaddr_in my_sockaddr)
* return: int 0 if it success
* Instead, the function returns:
* -1 : Connection time out
* -2 : wrong username
* .
* .
* .
*/
int my_send_packet(int socket, char *msg);