Помилка sendto IPX "," Помилка ", MB_OK + MB_ICONHAND);
closesocket (IPXSocket);
IPXSocket = INVALID_SOCKET;
Application-> Terminate ();
}
}
// ------------------------- розрив ------------------- --------------------------
void __ fastcall TMainForm :: IPXCloseConnection (void)
{
closesocket (IPXSocket);
WSACleanup ();
}
TCP.cpp
// --------------------------------------------- ------------------------------
# pragma hdrstop
# include "TCPIP.h"
# include "Main.h"
# include "Podkluch.h"
// --------------------------------------------- ------------------------------
# pragma package (smart_init)
extern bool IsServer;
extern bool IsHostName;
extern AnsiString ServerHostName;
extern AnsiString ServerHostIP;
extern int KolKub;
extern int MaxOch;
// ---------- Підключення ---------------------------------- -----------------
void __ fastcall TMainForm :: TCPIPConnect (void)
{
if (IsServer == true)
{
ClientSocket1-> Close ();
ServerSocket1-> Open ();
}
else
{
ServerSocket1-> Close ();
if (IsHostName)
ClientSocket1-> Host = ServerHostName;
else
ClientSocket1-> Host = ServerH ostIP;
ClientSocket1-> Open ();
}
}
// --------- Accept ----------------------------------- ----------------------------
void __ fastcall TMainForm :: ServerSocket1Accept (TObject * Sender,
TCustomWinSocket * Socket)
{
char * StrPered = DannieToChar (0, KolKub, MaxOch);
TCPIPSend (AnsiString (strPered));
InterfaceBeginNewGame ();
ChangeInterfacePerehodHoda (1);
}
// ---------- Відправка ---------------------------------- --------------------------
void __ fastcall TMainForm :: TCPIPSend (AnsiString strSend)
{
if (IsServer)
ServerSocket1-> Socket-> Connections [0] -> SendText (strSend);
else
ClientSocket1-> Socket-> SendText (strSend);
В
}
// ------------- Отримання ------------------------------- -------------------------
void __ fastcall TMainForm :: ServerSocket1ClientRead (TObject * Sender,
TCustomWinSocket * Socket)
{
if (IsVisitApplicationBox) return;
AnsiString strPriem = Socket-> ReceiveText ();
Priem (CharToMas (strPriem.c_str ()));
}
// --------------------------------------------- ------------------------------
void __ fastcall TMainForm :: ServerSocket1ClientConnect (TObject * Sender,
TCustomWinSocket * Socket)
{
//
}
// --------------------------------------------- ------------------------------
void __ fastcall TMainForm :: ClientSocket1Connect (TObject * Sender,
TCustomWinSocket * Socket)
{
// StatusBar1-> Panels-> Items [0] -> Text = "Connect to:" + Socket-> RemoteHost;
}
// --------------------------------------------- ------------------------------
void __ fastcall TMainForm :: ServerSocket1Listen (TObject * Sender,
TCustomWinSocket * Socket)
{
// StatusBar1-> Panels-> Items [0] -> Text = "Listening ...";
}
// -------------- Розрив з'єднання ----------------------------- --------------
void __ fastcall TMainForm :: TCPIPCloseConnection (void)
{
ServerSocket1-> Close ();
ClientSocket1-> Close ();
}
// ----------- Обробка помилок ------------------------------------------------- -
void __ fastcall TMainForm :: ClientSocket1Error (TObject * Sender,
TCustomWinSocket * Socket, TErrorEvent ErrorEvent, int & ErrorCode)
{
if (ErrorEvent == eeConnect)
{
ErrorCode = 0;
Application-> MessageBox ("Не вдалося здійснити з'єднання з сервером. nУбедітесь, що сервер очікує запиту клієнта. "," Помилка ", MB_OK + MB_ICONHAND);
}
else
{
Application-> MessageBox ("Помилка TCP/IP "," Помилка ", MB_OK + MB_ICONHAND);
Application-> Terminate ();
}
}
void __ fastcall TMainForm :: ServerSocket1ClientError (TObject * Sender,
TCustomWinSocket * Socket, TErrorEvent ErrorEvent, int & ErrorCode)
{
//
}
// --------------------------------------------- --------------------------------
Netbios.cpp
// --------------------------------------------- ------------------------------
# pragma hdrstop
# include
# include
# include
# include "NetBios.h"
# include "Main.h"...