-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproj1_client.cc
68 lines (51 loc) · 1.53 KB
/
proj1_client.cc
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
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include "packet.h" // defined by us
#include "proj1_client.h" // some supporting functions.
using std::cout;
using std::cerr;
using std::endl;
int main(int argc, char *argv[])
{
char * server_name_str = 0;
unsigned short int tcp_server_port;
unsigned short int udp_server_port;
struct My_Packet outgoing_pkt;
// prase the argvs, obtain server_name and tcp_server_port
parse_argv(argc, argv, &server_name_str, tcp_server_port);
cout << "[SYS] Bulls and Cows client started..." << endl;
cout << "[TCP] Connecting to server: " << server_name_str
<< ":" << tcp_server_port << endl;
while(1)
{
// TCP: CONNECT TO SERVER
// TCP: THE FIRST COMMAND MUST BE JOIN
// THE RESPONSE MUST BE JOIN_GRANT WITH A UDP PORT NUMBER
// GOT THE PORT NUMBER
// EXIT THE LOOP AND CONTINUES TO UDP GAME PLAY
}
// Game play using UDP
cout << "[UDP] Guesses will be sent to: " << server_name_str
<< " at port:" << udp_server_port << endl;
while(1)
{
// GAME PLAY IN UDP
//
while(get_command(outgoing_pkt) == false){}
// UDP: SEND/RECV INTERACTIONS
}
return 0;
}