Click here to Skip to main content
15,908,776 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Two Errors LNK2001 and LNK1120 Pin
Christian Graus17-May-02 13:50
protectorChristian Graus17-May-02 13:50 
Generalunace.dll Pin
carrie17-May-02 13:11
carrie17-May-02 13:11 
GeneralRe: unace.dll Pin
Mukkie18-May-02 0:38
Mukkie18-May-02 0:38 
Generalsimple question Pin
rbc17-May-02 12:50
rbc17-May-02 12:50 
GeneralRe: simple question Pin
Jack Handy17-May-02 13:34
Jack Handy17-May-02 13:34 
GeneralRe: simple question Pin
rbc17-May-02 14:00
rbc17-May-02 14:00 
GeneralRe: simple question Pin
rbc17-May-02 14:09
rbc17-May-02 14:09 
GeneralUDP broadcast again!! Pin
Rickard Andersson2017-May-02 12:34
Rickard Andersson2017-May-02 12:34 
Now there is some errors in my code, but it's late now and I have to go to bed! Frown | :(

But can you tell me how to do this:

// dir_bcast_addr is a u_long and is wron type to fit..
bcast.sin_addr.s_addr = inet_addr(dir_bcast_addr);

int main()
{
	// Starta Winsock
    WSAData wsaData;
	int nCode;
    if ((nCode = WSAStartup(MAKEWORD(2, 0), &wsaData)) != 0)
	{
		cout << "Ett fel inträffades när Winsock skulle startas, felkod " << nCode << "." << endl;
        return 1;
    }

	SOCKET       s;
	BOOL         bBroadcast;
	char         *sMsg = "This is a test";

	SOCKADDR_IN bcast;

	s = WSASocket(AF_INET, SOCK_DGRAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED);

	bBroadcast = TRUE;

	setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&bBroadcast, sizeof(BOOL));

	u_long host_addr = inet_addr("192.169.244.152");   // local IP addr
    u_long net_mask = inet_addr("255.255.255.128");   // LAN netmask
    u_long net_addr = host_addr & net_mask;         
    u_long dir_bcast_addr = net_addr | (~net_mask);


	bcast.sin_family = AF_INET;
	bcast.sin_addr.s_addr = inet_addr(dir_bcast_addr);
	bcast.sin_port = htons(5150);

	sendto(s, sMsg, strlen(sMsg), 0, (SOCKADDR *)&bcast, sizeof(bcast));

	while(TRUE)
	{
		char* buffer = new char[1024];
		SOCKADDR_IN sender;
		int sos = sizeof(sender);

		int ret = recvfrom(s, buffer, sizeof(buffer), MSG_OOB, (SOCKADDR*)&sender, &sos);
		
		if (ret == SOCKET_ERROR)
        {
            printf("recvfrom() failed; %d\n", WSAGetLastError());
            break;
        }
        else if (ret == 0)
		{
            break;
		}
        else
        {
            buffer[ret] = '\0';
            printf("[%s] sent me: '%s'\n", inet_ntoa(sender.sin_addr), buffer);
        }

		delete [] buffer;
	}

	closesocket(s);
	WSACleanup();

	return 0;
}


The error code is 10045 and it means that the function call or something is nott allowed!!??? WTF | :WTF: WTF | :WTF: WTF | :WTF:

Now I have to go and sleep!
See ya to morrow!

Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
GeneralCListView.. OnPaint().. Help! Pin
RobJones17-May-02 11:33
RobJones17-May-02 11:33 
GeneralRe: CListView.. OnPaint().. Help! Pin
Shog917-May-02 14:30
sitebuilderShog917-May-02 14:30 
GeneralSame problem :( Pin
17-May-02 14:42
suss17-May-02 14:42 
GeneralRe: Same problem :( Pin
Shog917-May-02 15:52
sitebuilderShog917-May-02 15:52 
GeneralThanks! Pin
RobJones20-May-02 6:18
RobJones20-May-02 6:18 
GeneralMAPIAddress() and the default button Pin
Shog917-May-02 11:23
sitebuilderShog917-May-02 11:23 
GeneralCTreeCtrl issues Pin
dazinith17-May-02 10:33
dazinith17-May-02 10:33 
GeneralRe: CTreeCtrl issues Pin
Ravi Bhavnani17-May-02 11:06
professionalRavi Bhavnani17-May-02 11:06 
GeneralRe: CTreeCtrl issues Pin
dazinith20-May-02 3:59
dazinith20-May-02 3:59 
GeneralProblems with MNEMONICS !! Pin
Cris17-May-02 10:25
Cris17-May-02 10:25 
GeneralRe: Problems with MNEMONICS !! Pin
Ravi Bhavnani17-May-02 11:07
professionalRavi Bhavnani17-May-02 11:07 
GeneralRe: Problems with MNEMONICS !! Pin
Cris20-May-02 2:18
Cris20-May-02 2:18 
QuestionQT, anyone? Pin
Ravi Bhavnani17-May-02 9:45
professionalRavi Bhavnani17-May-02 9:45 
QuestionSetting an environment variable? Pin
Jamie Hale17-May-02 9:22
Jamie Hale17-May-02 9:22 
AnswerRe: Setting an environment variable? Pin
Jamie Hale17-May-02 9:25
Jamie Hale17-May-02 9:25 
GeneralStatus Bar height Pin
Stan the man17-May-02 8:38
Stan the man17-May-02 8:38 
GeneralRe: Status Bar height Pin
Mike.NET17-May-02 9:04
Mike.NET17-May-02 9:04 

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.