Click here to Skip to main content
15,885,216 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCFileDialog problem Pin
Aamir Butt28-Jan-05 3:29
Aamir Butt28-Jan-05 3:29 
GeneralRe: CFileDialog problem Pin
Blake Miller28-Jan-05 3:58
Blake Miller28-Jan-05 3:58 
GeneralRe: CFileDialog problem Pin
David Crow28-Jan-05 4:10
David Crow28-Jan-05 4:10 
GeneralRe: CFileDialog problem Pin
Aamir Butt28-Jan-05 4:33
Aamir Butt28-Jan-05 4:33 
GeneralRe: CFileDialog problem Pin
David Crow28-Jan-05 5:21
David Crow28-Jan-05 5:21 
GeneralRe: CFileDialog problem Pin
Aamir Butt30-Jan-05 18:24
Aamir Butt30-Jan-05 18:24 
Generalcall for help Pin
yanyu8128-Jan-05 3:25
yanyu8128-Jan-05 3:25 
GeneralCall For Help Pin
yanyu8128-Jan-05 3:21
yanyu8128-Jan-05 3:21 
I had developed the client program under Visual C++ 6.0. I use the Windows socket programming. I compile and build my program using the Win32 Console application.There is no errors and warnings. But after I executing the program, I found that if(argc < 3) {
printf("usage: %s <server> <data1> <data2> ... <datan>\n",argv[0]);
exit(1);
}

the output is usage: %s <server> <data1> <data2> ... <datan> and stop with executing the rest of the program.My work is to send data to the server PC which is under the Linux environment.

The following is my program:Thanks for helping.

#include <stdio.h>
#include <winsock.h>
#include <windows.h>
#define SERVER_PORT 1500
#define MAX_MSG 100

//int CreatFile(char *szServer, short nPort);

//*CreatFile();

int main (int argc, char *argv[]) {


WORD wVersionRequested = MAKEWORD(1,1);
WSADATA wsaData;
int nRet;

//
// Initialize WinSock and check the version
//
nRet = WSAStartup(wVersionRequested, &wsaData);
if (wsaData.wVersion != wVersionRequested)
{
fprintf(stderr,"\n Wrong version\n");
return 0;
}


int sd, rc, i;
struct sockaddr_in localAddr, servAddr;
struct hostent *h;

if(argc < 3) {
printf("usage: %s <server> <data1> <data2> ... <datan>\n",argv[0]);
exit(1);
}


// The gethostbyname() function is used when we have the DNS name of our server
h = gethostbyname(argv[1]);
if(h==NULL) {
printf("%s: unknown host '%s'\n",argv[0],argv[1]);
exit(1);
}

//
// Fill in the address structure
//

servAddr.sin_family = h->h_addrtype;
memcpy((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
servAddr.sin_port = htons(SERVER_PORT);

/* create socket */
sd = socket(AF_INET, SOCK_STREAM, 0);
if(sd<0) {
perror("cannot open socket ");
exit(1);
}

/* bind any port number */
localAddr.sin_family = AF_INET;
localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
localAddr.sin_port = htons(0);

rc = bind(sd, (struct sockaddr *) &localAddr, sizeof(localAddr));
if(rc<0) {
printf("%s: cannot bind port TCP %u\n",argv[0],SERVER_PORT);
perror("error ");
exit(1);
}

/* connect to server */
rc = connect(sd, (struct sockaddr *) &servAddr, sizeof(servAddr));
if(rc<0) {
perror("cannot connect ");
exit(1);
}

for(i=2;i
GeneralRe: Call For Help Pin
David Crow28-Jan-05 4:04
David Crow28-Jan-05 4:04 
GeneralRe: Call For Help Pin
yanyu8128-Jan-05 14:06
yanyu8128-Jan-05 14:06 
GeneralRe: Call For Help Pin
David Crow28-Jan-05 15:04
David Crow28-Jan-05 15:04 
GeneralRe: Call For Help Pin
yanyu8130-Jan-05 4:27
yanyu8130-Jan-05 4:27 
GeneralRe: Call For Help Pin
David Crow31-Jan-05 2:24
David Crow31-Jan-05 2:24 
GeneralDecryption Pin
gecool28-Jan-05 2:55
gecool28-Jan-05 2:55 
GeneralUnicode CString init from &amp;#XXXX;&amp;#YYYY; representation Pin
lob28-Jan-05 1:17
lob28-Jan-05 1:17 
GeneralRe: Unicode CString init from &amp;#XXXX;&amp;#YYYY; representation Pin
includeh1028-Jan-05 7:49
includeh1028-Jan-05 7:49 
GeneralRe: Unicode CString init from &amp;#XXXX;&amp;#YYYY; representation Pin
lob28-Jan-05 9:30
lob28-Jan-05 9:30 
GeneralConsole Output Pin
IronMike27-Jan-05 23:51
IronMike27-Jan-05 23:51 
GeneralRe: Console Output Pin
trelliot28-Jan-05 2:33
trelliot28-Jan-05 2:33 
GeneralRe: Console Output Pin
IronMike28-Jan-05 3:06
IronMike28-Jan-05 3:06 
GeneralRe: Console Output Pin
V.28-Jan-05 2:47
professionalV.28-Jan-05 2:47 
GeneralRe: Console Output Pin
IronMike28-Jan-05 3:09
IronMike28-Jan-05 3:09 
GeneralSolution: Console Output Pin
IronMike31-Jan-05 21:38
IronMike31-Jan-05 21:38 
GeneralHorizental Scroll is not Appearing in CCheckListBox .. Urgent Pin
zahid_ash27-Jan-05 23:38
zahid_ash27-Jan-05 23:38 
GeneralRe: Horizental Scroll is not Appearing in CCheckListBox .. Urgent Pin
tanvon malik28-Jan-05 2:22
tanvon malik28-Jan-05 2:22 

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.