Beispiel #1
0
void login(struct USER *me) {
    int recvd;
    if (isconnected) {
        fprintf(stderr, "You are already connected to server at %s:%d\n", SERVERIP, SERVERPORT);
        return;
    }
    sockfd = connect_with_server();
    if (sockfd >= 0) {
        isconnected = 1;
        me->sockfd = sockfd;
        if (strcmp(me->user, "Anonymous")) setuser(me);
        printf("Logged in as %s\n", me->user);
        printf("Receiver started [%d]...\n", sockfd);
        struct THREADINFO threadinfo;
        pthread_create(&threadinfo.thread_ID, NULL, receiver, (void *) &threadinfo);

    } else {
        fprintf(stderr, "Connection rejected...\n");
    }
}
Beispiel #2
0
void login(struct USER *me) {
    int recvd;
    if(isconnected) {
        fprintf(stderr, "Juz jestes zalogowany %s:%d\n", ipcon, portnom);
        return;
    }
    sockfd = connect_with_server();
    if(sockfd >= 0) {
        isconnected = 1;
        me->sockfd = sockfd;
        if(strcmp(me->alias, "Anonymous")) setalias(me);
        printf("Zalogowano jako %s\n", me->alias);
        printf("Nasluchiwanie rozpoczete [%d]...\n", sockfd);
        struct THREADINFO threadinfo;
        pthread_create(&threadinfo.thread_ID, NULL, receiver, (void *)&threadinfo);
 
    }
    else {
        fprintf(stderr, "Polaczenie odrzucone...\n");
    }
}
Beispiel #3
0
void login(struct USER *me) {
int recvd;
if(isconnected) {
fprintf(stderr, "You are already connected to server at %s:%d\n", SERVERIP, SERVERPORT);
return;
}
sockfd = connect_with_server();
if(sockfd >= 0) {
isconnected = 1;
me->sockfd = sockfd;
if(strcmp(me->user, "default")) setuser(me);
printf(pink "Logged in as %s\n" ANSI_COLOR_RESET, me->user);
printf(ANSI_COLOR_YELLOW "ready to send and receive messages [%d]\n" ANSI_COLOR_RESET, sockfd);
sleep(1);
struct THREADINFO threadinfo;
pthread_create(&threadinfo.thread_ID, NULL, receiver, (void *)&threadinfo);

}
else {
fprintf(stderr, "Connection rejected...\n");
}
}
void SctpClient::conn(string arg_server_ip_addr, int arg_server_port) {
	init(arg_server_ip_addr, arg_server_port);
	g_nw.set_rcv_timeout(conn_fd, 1);
	connect_with_server();
}
void SctpClient::conn(string arg_server_ip_addr, int arg_server_port) {
	//cout<<"Estd Conn"<<endl;
	init(arg_server_ip_addr, arg_server_port);
	// g_nw.set_rcv_timeout(conn_fd, 1);
	connect_with_server();
}