Skip to content

Commit a004c0c

Browse files
committed
examples/server/repeater: use rfbUltraVNCRepeaterMode2Connection()
1 parent 722c7f8 commit a004c0c

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

examples/server/repeater.c

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ static void clientGone(rfbClientPtr cl)
3333

3434
int main(int argc,char** argv)
3535
{
36-
char *repeaterHost;
37-
int repeaterPort, sock;
38-
char id[250];
3936
rfbClientPtr cl;
4037

4138
int i,j;
@@ -47,14 +44,6 @@ int main(int argc,char** argv)
4744
"Usage: %s <id> <repeater-host> [<repeater-port>]\n", argv[0]);
4845
exit(1);
4946
}
50-
memset(id, 0, sizeof(id));
51-
if(snprintf(id, sizeof(id), "ID:%s", argv[1]) >= (int)sizeof(id)) {
52-
/* truncated! */
53-
fprintf(stderr, "Error, given ID is too long.\n");
54-
return 1;
55-
}
56-
repeaterHost = argv[2];
57-
repeaterPort = argc < 4 ? 5500 : atoi(argv[3]);
5847

5948
/* The initialization is identical to simple15.c */
6049
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,400,300,5,3,2);
@@ -77,21 +66,13 @@ int main(int argc,char** argv)
7766
/* Make sure to call this _before_ connecting out to the repeater */
7867
rfbInitServer(server);
7968

80-
sock = rfbConnectToTcpAddr(repeaterHost, repeaterPort);
81-
if (sock == RFB_INVALID_SOCKET) {
82-
perror("connect to repeater");
83-
return 1;
84-
}
85-
if (send(sock, id, sizeof(id),0) != sizeof(id)) {
86-
perror("writing id");
87-
return 1;
88-
}
89-
cl = rfbNewClient(server, sock);
69+
cl = rfbUltraVNCRepeaterMode2Connection(server, argv[2], argc < 4 ? 5500 : atoi(argv[3]), argv[1]);
70+
9071
if (!cl) {
91-
perror("new client");
92-
return 1;
72+
fprintf(stderr, "Connecting to repeater failed!\n");
73+
exit(EXIT_FAILURE);
9374
}
94-
cl->reverseConnection = 0;
75+
9576
cl->clientGoneHook = clientGone;
9677

9778
/* Run the server */

0 commit comments

Comments
 (0)