I. Local IP address and port
Char Buf [buf_size];
Sockaddr_in name;
Int nlen = sizeof (name );
Getsockname (g_cltskt, (sockaddr *) & name, & nlen );
Sprintf (BUF, "(% s: % d):", inet_ntoa (name. sin_addr), ntohs (name. sin_port ));
G_prefix = Buf;
Ii. remote IP address and port
S = accept (g_lsnskt, null, null );
Getpeername (S, (sockaddr *) & name, & namelen );
Sprintf (BUF, "a guest % s: % d has joined us./R/N", inet_ntoa (name. sin_addr ),
Ntohs (name. sin_port ));
3. How to refresh a multi-row scroll bar
Void refreshscreen (hwnd)
{
// Post the text first
Hwnd subwnd;
Subwnd = getdlgitem (hwnd, idc_text );
Setwindowtext (subwnd, g_text.c_str ());
// Set the scroll bar.
Int POs, N;
Pos = n = 0;
While (Pos = g_text.find ('/N', POS ))! =-1)
{
++ Pos;
++ N;
}
Sendmessage (subwnd, em_linescroll, 0, n); // The second to the last is the row scroll volume, and the first to the last is the column scroll volume.
}