Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo Leutz,

ich beschäftige mich seit letzter Woche mit Socket-Programmierung. Hierzu versuche ich mir WSADATA eine Verbindung gerzustellen. Leider scheitert dies schon am Initialisieren.

Ich habe folgenden Code:


int StartWinsock(void)

{

	WSADATA WSAData;

	return WSAStartup(MAKEWORD(2,0), &WSAData);

}

und bekomme folgende Meldungen:

c:\Dokumente und Einstellungen\Patrick\Eigene Dateien\Visual Studio Projects\Prototyp\Prototyp.cpp(123): error C2065: 'WSADATA' : undeclared identifier

c:\Dokumente und Einstellungen\Patrick\Eigene Dateien\Visual Studio Projects\Prototyp\Prototyp.cpp(123): error C2146: syntax error : missing ';' before identifier 'WSAData'

c:\Dokumente und Einstellungen\Patrick\Eigene Dateien\Visual Studio Projects\Prototyp\Prototyp.cpp(123): error C2065: 'WSAData' : undeclared identifier

c:\Dokumente und Einstellungen\Patrick\Eigene Dateien\Visual Studio Projects\Prototyp\Prototyp.cpp(124): error C3861: 'WSAStartup': identifier not found, even with argument-dependent lookup

c:\Dokumente und Einstellungen\Patrick\Eigene Dateien\Visual Studio Projects\Prototyp\Prototyp.cpp(124): error C3861: 'WSAData': identifier not found, even with argument-dependent lookup

Ich benutze als Entwicklungsoberfläche MS-Visual-Studio 2003 und als BS Windows XP. Keine Ahnung woran der Fehler liegen könnte, habe ich schon hier im Forum gesucht, aber keine funktionierende Lösung gefunden.

Gruß Patrick

  • Autor

Die Includierung Winsock2.h hatte ich gemacht, allerdings bekomme ich dann die Fehlermeldung:

#include <Winsock2.h>

c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxv_w32.h(18): fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

Du hättest auch gleich sagen können, dass du eine MFC-Anwendung hast.

Falls das Projekt noch nicht zu groß ist, solltest du es neu anlegen, und beim Assistenten die Unterstützung für Windows Sockets aktivieren.

Falls du das nicht willst oder kannst, probier mal das hier:

Setze ans Ende der stdafx.h:

#include <afxsock.h>
Setze folgendes in die InitInstance-Methode der App-Klasse, hinter den Aufruf von CWinApp::InitInstance:
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}[/code]

P.S.: Verschoben nach C++: Compiler, IDEs, APIs

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.