Click here to Skip to main content
15,914,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Polygon replacement. Pin
John R. Shaw10-Feb-05 10:15
John R. Shaw10-Feb-05 10:15 
GeneralShell Extensions and ShellExecuteEx Pin
MasamuneXGP9-Feb-05 12:57
MasamuneXGP9-Feb-05 12:57 
GeneralShould be simple: CFile Dialog filters Pin
JKallen9-Feb-05 12:56
JKallen9-Feb-05 12:56 
GeneralRe: Should be simple: CFile Dialog filters Pin
Chris Losinger10-Feb-05 3:58
professionalChris Losinger10-Feb-05 3:58 
GeneralRe: Should be simple: CFile Dialog filters Pin
JKallen11-Feb-05 11:42
JKallen11-Feb-05 11:42 
Generalproject path Pin
chints819-Feb-05 11:45
chints819-Feb-05 11:45 
GeneralRe: project path Pin
2249179-Feb-05 16:47
2249179-Feb-05 16:47 
GeneralWinsock Connect() Problems Pin
manofoblivion9-Feb-05 11:33
manofoblivion9-Feb-05 11:33 
I cannot create a working connection. I need help. Here is my source:


#include <winsock.h>
#include <string>
#include <sstream>
#include <iostream>

using namespace std;

string itos(int x){
ostringstream sStream;
sStream<<x<<flush;
return(sstream.str());
}

int="" main(int="" argc,="" char="" *argv[]){
="" fills="" array="" with="" ips
="" string="" iparray[255];
="" subnetarray[1]="192.168.1" ;
="" int="" rangestart,rangeend;
="" rangestart="5;
" rangeend="5;
" index="0;
" for(int="" x="rangeStart;x<=rangeEnd;x++){
" iparray[index]="subnetArray[0]+".";
" tmp="itos(x);
" iparray[index]+="tmp;
" index++;
="" }
="" wsa="" startup
="" wsadata="" wsadata;
="" if(wsastartup(makeword(1,1),&wsadata)!="0){
" cout<<"wsastartup="" failed!\n";
="" system("pause");
="" return="" exit_success;
=""
="" socketdescriptor;
="" socketdescriptor="socket(AF_INET,SOCK_STREAM,0);
" if(socketdescriptor<0){
="" cout<<"socket="" creation="" serverport="20100;
" struct="" hostent="" *hostinfo;
="" sockaddr_in="" serveraddress;
="" ip[20];
="" strcpy(&ip[0],iparray[index].c_str());
="" cout<<ip;
="" hostinfo="gethostbyname(IP);
" serveraddress.sin_family="hostInfo-">h_addrtype;
memcpy((char *)&serverAddress.sin_addr.s_addr,hostInfo->h_addr_list[0],hostInfo->h_length);
serverAddress.sin_port=htons(serverPort);
//cout<<endl<<endl<<serveraddress.sin_addr.s_addr;
if(connect(socketdescriptor,(struct="" sockaddr*)&serveraddress,sizeof(struct="" sockaddr))="=-1){
" cout<<"="" not="" connected"<<endl;
="" }
="" else{
=""


="" system("pause");
="" return="" exit_success;
}



and="" the="" other:

#include="" <winsock.h="">
#include <iostream>

using namespace std;

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

//wsa startup
WSADATA wsaData;
if(WSAStartup(MAKEWORD(1,1),&wsaData)!=0){
cout<<"WSAStartup failed!\n";
system("PAUSE");
return EXIT_SUCCESS;
}

int socketDescriptor;
socketDescriptor=socket(AF_INET,SOCK_STREAM,0);
if(socketDescriptor<0){
cout<<"Socket creation failed!\n";
system("PAUSE");
return EXIT_SUCCESS;
}
struct sockaddr_in myAddr;
myAddr.sin_family=AF_INET;
int serverPort=420100;
myAddr.sin_port=htons(serverPort);



char myIP[16];
gethostname(myIP,16);
myAddr.sin_addr.s_addr=inet_addr(myIP);
cout<<myip<<endl;

="" struct="" hostent="" *h;
="" h="gethostbyname(myIP);
" cout<<"hostname:="" "<<h-="">h_name<<endl;
cout<<"ip:="" "<<inet_ntoa(*((struct="" in_addr*)h-="">h_addr))<
GeneralRe: Winsock Connect() Problems Pin
rocky_pulley10-Feb-05 4:47
rocky_pulley10-Feb-05 4:47 
GeneralRe: Winsock Connect() Problems Pin
manofoblivion10-Feb-05 12:48
manofoblivion10-Feb-05 12:48 
Generalsearch the harddrive Pin
jonavon blakly9-Feb-05 11:05
jonavon blakly9-Feb-05 11:05 
GeneralRe: search the harddrive Pin
2249179-Feb-05 16:59
2249179-Feb-05 16:59 
Questionwhat does #line really do Pin
Jim Crafton9-Feb-05 10:00
Jim Crafton9-Feb-05 10:00 
AnswerRe: what does #line really do Pin
basementman9-Feb-05 10:36
basementman9-Feb-05 10:36 
AnswerRe: what does #line really do Pin
Ryan Binns9-Feb-05 17:32
Ryan Binns9-Feb-05 17:32 
GeneralDebug another Process Pin
Chris Meech9-Feb-05 9:19
Chris Meech9-Feb-05 9:19 
GeneralRe: Debug another Process Pin
Chris Losinger9-Feb-05 9:22
professionalChris Losinger9-Feb-05 9:22 
GeneralRe: Debug another Process Pin
Chris Meech9-Feb-05 9:40
Chris Meech9-Feb-05 9:40 
QuestionHow about this... Pin
bilas9-Feb-05 8:57
bilas9-Feb-05 8:57 
AnswerRe: How about this... Pin
Neville Franks9-Feb-05 10:20
Neville Franks9-Feb-05 10:20 
GeneralRe: How about this... Pin
bilas10-Feb-05 6:32
bilas10-Feb-05 6:32 
Generaldefining a string constant Pin
K. Shaffer9-Feb-05 7:14
K. Shaffer9-Feb-05 7:14 
GeneralRe: defining a string constant Pin
K. Shaffer9-Feb-05 7:22
K. Shaffer9-Feb-05 7:22 
GeneralRe: defining a string constant Pin
Chris Losinger9-Feb-05 9:24
professionalChris Losinger9-Feb-05 9:24 
GeneralRe: defining a string constant Pin
K. Shaffer9-Feb-05 10:26
K. Shaffer9-Feb-05 10:26 

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.