Click here to Skip to main content
15,926,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Reusing a std::vector<> object after performing an erase() Pin
Mike Burston18-Oct-01 13:05
Mike Burston18-Oct-01 13:05 
GeneralRe: Reusing a std::vector<> object after performing an erase() Pin
George Anescu18-Oct-01 5:29
George Anescu18-Oct-01 5:29 
GeneralColored Rectangles as background Pin
18-Oct-01 2:33
suss18-Oct-01 2:33 
GeneralRe: Colored Rectangles as background Pin
kumar_p318-Oct-01 3:01
kumar_p318-Oct-01 3:01 
Generala question Pin
The_Server18-Oct-01 2:27
The_Server18-Oct-01 2:27 
GeneralRe: a question Pin
Andres Manggini18-Oct-01 7:12
Andres Manggini18-Oct-01 7:12 
GeneralRe: Or use WinSock API! Pin
Masaaki Onishi18-Oct-01 8:39
Masaaki Onishi18-Oct-01 8:39 
GeneralRe: a question Pin
Net Guy18-Oct-01 9:32
Net Guy18-Oct-01 9:32 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winsock2.h>
#define WINSOCKVER    MAKEWORD(2,0)
#pragma comment(lib, "wsock32.lib")
  

#pragma comment (lib, "ws2_32.lib") // link socket


int main()
{
 int i, j; // return values
 int port=80; // port number
 char temp[1]; // just a thingy :)
 char host[512]="localhost";   // for now 127.0.0.1 but wanted to show how to resolve it :)
 SOCKADDR_IN	ss_addr;  // some thing has to d with sock addr

 char request[MAX_PATH]="the buffer content goes here";
 hostent FAR *   he; // ip addreess after we resove it :P
   

 printf("Send Buffer \n");
 printf("By Net Guy\n");

 WSADATA	wsdata; 

 //initialize the Windows Socket DLL
    if( WSAStartup(WINSOCKVER, &wsdata) != 0 ) 
       exit (1);

 if((he=gethostbyname(host)) == NULL) 
	{
 	 fprintf(stderr, "invalid target\n");
	 exit (-1);
	}


	 ss_addr.sin_family = PF_INET; in
 	 ss_addr.sin_port = htons(port);
 	 memcpy((char *) &ss_addr.sin_addr, (char *) he->h_addr, 
 		sizeof(ss_addr.sin_addr));	

	 // create socket
 	 if((i=socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) 
		 {
	 	  fprintf(stderr, "cannot create socket\n");
	 	  exit(-1);
		 }

	 // connect since we are tcp not udp 
 	 j = connect(i, (struct sockaddr *) &ss_addr, sizeof(ss_addr));
 
 	 if(j==-1) 
		 {
	 	  fprintf(stderr, "cannot connect to %s\n", host);
	 	  exit(-1);
	 	 }

	 printf("]- Sending request: %s\n", request);
	 // send the buffer
 	 send(i, request, strlen(request), 0);

	 // receive all unless nothing is there
 	 while(recv(i,temp,1, 0)>0) 
		 {
   	 	  printf("%c", temp[0]);
   		 }	
	
	 // to lazy to clean up
	 // do clean up		 
return 0;
}

GeneralRe: a question Pin
The_Server21-Oct-01 1:00
The_Server21-Oct-01 1:00 
GeneralDynamic CMenu* Pin
Chambers18-Oct-01 1:03
Chambers18-Oct-01 1:03 
GeneralRe: Dynamic CMenu* Pin
Jon Hulatt18-Oct-01 1:40
Jon Hulatt18-Oct-01 1:40 
GeneralRe: Dynamic CMenu* Pin
kumar_p318-Oct-01 2:17
kumar_p318-Oct-01 2:17 
Generaldropdown toolbars when writing a shell namespace extension Pin
18-Oct-01 0:42
suss18-Oct-01 0:42 
GeneralConverting a CString into a CPoint Pin
18-Oct-01 0:37
suss18-Oct-01 0:37 
GeneralRe: Converting a CString into a CPoint Pin
Christian Graus18-Oct-01 2:20
protectorChristian Graus18-Oct-01 2:20 
GeneralCreateIconFromResource and cursor : plz help Pin
pepeR18-Oct-01 0:30
pepeR18-Oct-01 0:30 
GeneralTask Manager Pin
18-Oct-01 0:22
suss18-Oct-01 0:22 
GeneralRe: Task Manager Pin
kumar_p318-Oct-01 2:36
kumar_p318-Oct-01 2:36 
GeneralPalettes Pin
jerry0davis17-Oct-01 23:16
jerry0davis17-Oct-01 23:16 
GeneralRe: Palettes Pin
Jon Hulatt17-Oct-01 23:52
Jon Hulatt17-Oct-01 23:52 
GeneralRe: Palettes Pin
jerry0davis18-Oct-01 0:15
jerry0davis18-Oct-01 0:15 
GeneralThreads Pin
The_Server17-Oct-01 23:00
The_Server17-Oct-01 23:00 
GeneralRe: Threads Pin
Jon Hulatt17-Oct-01 23:50
Jon Hulatt17-Oct-01 23:50 
GeneralRe: Threads Pin
kumar_p318-Oct-01 3:09
kumar_p318-Oct-01 3:09 
QuestionHow to maintain scrol bar Pin
binnu17-Oct-01 22:55
binnu17-Oct-01 22:55 

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.