Click here to Skip to main content
15,916,019 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionEM_SETSEL - Clearing Selection? Pin
Blake V. Miller7-Jun-04 15:37
Blake V. Miller7-Jun-04 15:37 
AnswerRe: EM_SETSEL - Clearing Selection? Pin
Ryan Binns7-Jun-04 18:02
Ryan Binns7-Jun-04 18:02 
GeneralRe: EM_SETSEL - Clearing Selection? Pin
Blake V. Miller7-Jun-04 18:14
Blake V. Miller7-Jun-04 18:14 
GeneralRe: EM_SETSEL - Clearing Selection? Pin
Blake V. Miller7-Jun-04 18:16
Blake V. Miller7-Jun-04 18:16 
QuestionStatic or nonstatic member function? Pin
Vicord Chrane7-Jun-04 15:23
Vicord Chrane7-Jun-04 15:23 
AnswerRe: Static or nonstatic member function? Pin
Ryan Binns7-Jun-04 18:05
Ryan Binns7-Jun-04 18:05 
GeneralEnumerating Internet Ports Pin
Archer2827-Jun-04 13:24
Archer2827-Jun-04 13:24 
GeneralCan't Connect to the server Pin
osal7-Jun-04 11:50
osal7-Jun-04 11:50 
I have a problem connecting to a server that I'm writing in C.

I'm working on this client program in C, but it can never connect to the server. The Server is coded in C as well, but it is in UNIX, this is for my work. Basically they want me to code the client program in Windows so they can have a windows version running, however, I can never get it to get authorization from the server. The part where it rejects me is below

Code:

// server.c

/* The client makes a simple identification */
if(fgets(line,MAXLINE,fdr) == NULL) goto finish;
/*if(sscanf(line,"%s %s %s",who,passwd,version) != 3) goto finish;*/
strcpy(interface, "stpc");
if(sscanf(line, "%s %s %s %s",who,passwd,version,interface) < 3) goto finish;
// this printf ensures that line has an interface
// for the logs
sprintf(line, "%s %s %s %s\n",who,passwd,version,interface);
if(strcmp(passwd,PASSWD) != 0) goto finish;
fprintf(stplog," %s %s %s",timestamp(),whoami,line);
fflush(stplog);

/* Let the client know we are connected */
fprintf(fdw,"CONNECTED\n");
fflush(fdw);


that was the server portion, and now below is the one I am trying to code, which is in windows.

Code:

fd_rd = _open_osfhandle(ws_sockfd, 0);

if (fd_rd == -1) exit(-1);


ws_fdr= fdopen(fd_rd,"r");

ws_fdw= fdopen(fd_rd,"w");




if( ws_fdr == NULL || ws_fdw == NULL)
err(FATAL,"STP: cannot open ws_fdw/ws_fdr\n");

/* send authorization */

printf("Sending authorization!\n");
sprintf(line,"%s %s %s %s\n","STP",PASSWD,VERSION,"stpc"); // sets line to the ip, password, version, and interface

ws_putline(line);
fflush(ws_fdw);
printf("Authorization sent, awaiting confirmation!\n");

/* get connection acknowledgement */

/*

Below is where we get our
Connection failures


*/
ws_getline(line,MAXLINE);
if(strcmp(line,"CONNECTED\n") != 0) {
err(WARN,"STP: Connection rejected by waveserver - %s\n", line);
continue;
}

Basically it's trying to send the server the info, which are the password, version, interface and STP. and then the server should verify it and then say OK, and copy "CONNECTED\n" into line, and the we should be connected. On UNIX, both the client program and Server work fine. Please help, thanks.
Questionis application open? Pin
pnpfriend7-Jun-04 10:00
pnpfriend7-Jun-04 10:00 
AnswerRe: is application open? Pin
David Crow7-Jun-04 10:48
David Crow7-Jun-04 10:48 
AnswerRe: is application open? Pin
Archer2827-Jun-04 13:21
Archer2827-Jun-04 13:21 
GeneralCArray Pin
brdavid7-Jun-04 9:56
brdavid7-Jun-04 9:56 
GeneralRe: CArray Pin
David Crow7-Jun-04 10:33
David Crow7-Jun-04 10:33 
GeneralRe: CArray Pin
brdavid7-Jun-04 11:41
brdavid7-Jun-04 11:41 
Generalselect a single file right click menu Pin
skoizumi291107-Jun-04 9:20
sussskoizumi291107-Jun-04 9:20 
GeneralRe: select a single file right click menu Pin
David Crow7-Jun-04 10:07
David Crow7-Jun-04 10:07 
GeneralRe: select a single file right click menu Pin
skoizumi291107-Jun-04 10:20
sussskoizumi291107-Jun-04 10:20 
GeneralRe: select a single file right click menu Pin
David Crow11-Jun-04 2:04
David Crow11-Jun-04 2:04 
GeneralRe: select a single file right click menu Pin
skoizumi2911013-Jun-04 15:34
sussskoizumi2911013-Jun-04 15:34 
GeneralRe: select a single file right click menu Pin
David Crow14-Jun-04 2:32
David Crow14-Jun-04 2:32 
GeneralCreateThread and Hooks Pin
Spiritofamerica7-Jun-04 8:29
Spiritofamerica7-Jun-04 8:29 
GeneralRe: CreateThread and Hooks Pin
David Crow7-Jun-04 8:59
David Crow7-Jun-04 8:59 
GeneralRe: CreateThread and Hooks Pin
Blake V. Miller7-Jun-04 15:34
Blake V. Miller7-Jun-04 15:34 
GeneralRe: CreateThread and Hooks Pin
Ryan Binns7-Jun-04 18:22
Ryan Binns7-Jun-04 18:22 
GeneralRe: CreateThread and Hooks Pin
Spiritofamerica7-Jun-04 19:48
Spiritofamerica7-Jun-04 19:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.