-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsender.cpp
More file actions
45 lines (36 loc) · 730 Bytes
/
Copy pathsender.cpp
File metadata and controls
45 lines (36 loc) · 730 Bytes
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
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<cstdlib>
#include<string.h>
#include<sstream>
#include<ctime>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<map>
#define port 6000
using namespace std;
struct sockaddr_in serv_addr;
int main()
{
int i,rc,s;
s = socket(PF_INET, SOCK_DGRAM, 0);
if (s < 0)
{
perror ("socket() failed\n");
exit(1);
}
void *data;
size_t len;
ssize_t bytes;
char msg[100];
string text="rebel berry";
//data = &msg;
strcpy(msg, text.c_str());
len = sizeof msg;
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
bytes = sendto(s, msg, len, 0, (struct sockaddr*)&serv_addr, sizeof serv_addr);
}