Click here to Skip to main content
16,007,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: sndPlaySound doesn't work Pin
Joshua Nussbaum21-Oct-02 12:05
Joshua Nussbaum21-Oct-02 12:05 
GeneralRe: sndPlaySound doesn't work Pin
Jh321-Oct-02 12:33
Jh321-Oct-02 12:33 
GeneralRe: sndPlaySound doesn't work Pin
Joshua Nussbaum21-Oct-02 12:38
Joshua Nussbaum21-Oct-02 12:38 
GeneralRe: sndPlaySound doesn't work Pin
Jh321-Oct-02 12:41
Jh321-Oct-02 12:41 
GeneralRe: sndPlaySound doesn't work Pin
Joshua Nussbaum21-Oct-02 13:43
Joshua Nussbaum21-Oct-02 13:43 
GeneralRe: sndPlaySound doesn't work Pin
Jh321-Oct-02 14:18
Jh321-Oct-02 14:18 
GeneralProcessID of a window Pin
Joshua Nussbaum21-Oct-02 10:30
Joshua Nussbaum21-Oct-02 10:30 
Generalinet_addr(...) problem Pin
Rickard Andersson2021-Oct-02 10:23
Rickard Andersson2021-Oct-02 10:23 
I have done two classes, CTcpServer and CTcpCLient. I think they are self explained!?
In CTcpServer's Bind() method I get an error when I pass a dotted IP string instead of a DNS. It says "Memory cannot be read" or something...

String is a typedef char*
EndPoint is a structure that looks like this:

struct EndPoint
{
String host;
int port;
}

void CTcpServer::Bind(EndPoint ep) const
{
	if(IsSocketOK() == 0)
	{
		throw CSocketException(WSAGetLastError());
	}
	
	EndPoint endpoint = ep;
	sockaddr_in config;

    config.sin_family =	AF_INET;
    config.sin_port = htons((u_short)endpoint.port);
	
	if(endpoint.host == NULL)
	{
		config.sin_addr.S_un.S_addr = INADDR_ANY;
	}
	else
	{
		if(inet_addr(endpoint.host) == INADDR_NONE)
		{
			LPHOSTENT hostentry = gethostbyname(endpoint.host);
			config.sin_addr.S_un.S_addr = *((unsigned long*)hostentry->h_addr);
		}
		else
		{
			String ip = inet_ntoa(*(LPIN_ADDR)*(endpoint.host));
			config.sin_addr.S_un.S_addr = inet_addr(ip);
		}
	}

	if(bind(m_ServerSocket, (sockaddr*)&config, sizeof(config)) != 0)
    {
		throw CSocketException(WSAGetLastError());
    }
}


I want it possible to write either a DNS or dotted IP.

What is wroooong!!!
I'm tired, good night!

Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!

UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!

GeneralRe: inet_addr(...) problem Pin
Anonymous21-Oct-02 10:39
Anonymous21-Oct-02 10:39 
GeneralRe: inet_addr(...) problem Pin
Rickard Andersson2021-Oct-02 21:28
Rickard Andersson2021-Oct-02 21:28 
GeneralDetecting a file close event Pin
Harold Bamford21-Oct-02 9:50
Harold Bamford21-Oct-02 9:50 
GeneralRe: Detecting a file close event Pin
Neville Franks21-Oct-02 11:31
Neville Franks21-Oct-02 11:31 
GeneralRe: Detecting a file close event Pin
Harold Bamford21-Oct-02 11:40
Harold Bamford21-Oct-02 11:40 
GeneralRe: Detecting a file close event Pin
Joaquín M López Muñoz21-Oct-02 11:47
Joaquín M López Muñoz21-Oct-02 11:47 
GeneralRe: Detecting a file close event Pin
Harold Bamford21-Oct-02 11:56
Harold Bamford21-Oct-02 11:56 
GeneralRe: Detecting a file close event Pin
Neville Franks21-Oct-02 12:01
Neville Franks21-Oct-02 12:01 
GeneralRe: Detecting a file close event Pin
Harold Bamford22-Oct-02 8:29
Harold Bamford22-Oct-02 8:29 
GeneralMonitoring a Temperature/C++ Pin
LostInC++21-Oct-02 9:48
LostInC++21-Oct-02 9:48 
GeneralRe: Monitoring a Temperature/C++ Pin
Joaquín M López Muñoz21-Oct-02 10:06
Joaquín M López Muñoz21-Oct-02 10:06 
GeneralMonitoring a Temperature Value using C++ Pin
LostInC++21-Oct-02 9:47
LostInC++21-Oct-02 9:47 
GeneralRe: Monitoring a Temperature Value using C++ Pin
LostInC++21-Oct-02 10:48
LostInC++21-Oct-02 10:48 
GeneralCustom draw a CTreeCtrl View Pin
Anonymous21-Oct-02 9:44
Anonymous21-Oct-02 9:44 
GeneralIs there a function for determining the number of sub items? Pin
21-Oct-02 10:50
suss21-Oct-02 10:50 
QuestionCreateProcess Window Closes When Program Exits, WHY? Pin
mediamaster4021-Oct-02 9:44
mediamaster4021-Oct-02 9:44 
AnswerRe: CreateProcess Window Closes When Program Exits, WHY? Pin
Mike Nordell21-Oct-02 21:13
Mike Nordell21-Oct-02 21:13 

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.