I have solved the problem... removing the bind() function execution. Acording with the MSDN documentation: "The bind function is used on an unconnected socket before subsequent calls to the connect or listen functions. It is used to bind to either connection-oriented (stream) or connectionless (datagram) sockets. When a socket is created with a call to the socket function, it exists in a namespace (address family), but it has no name assigned to it. Use the bind function to establish the local association of the socket by assigning a local name to an unnamed socket." I understood that the bind function is not necessary, because I only want to send datagrams with a SOCKET to server and receive the responses by the same SOCKET, and the WSAAsyncSelect function grants the data response to the app. This is correct? Thanks, Cris.
Cris
Posts
-
UDP Application on Vista: Fail on sendto function -
UDP Application on Vista: Fail on sendto functionNo, the UAC configuration is not enabled.
-
UDP Application on Vista: Fail on sendto functionThis is my code:
SOCKET m_maSocketOut; struct sockaddr_in m_SockAddrOut; unsigned long m_lInet; . . void init(CString strServer) { unsigned long lInet=0; memset(&m_SockAddrOut, 0, sizeof(m_SockAddrOut)); m_maSocketOut = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); m_SockAddrOut.sin_family = AF_INET; m_SockAddrOut.sin_port = htons(port); struct hostent FAR* hp = gethostbyname((char FAR *) (const char *) strServer); if (hp == NULL) { lInet = inet_addr((const char * ) strServer); if (lInet != INADDR_NONE) { validIP = TRUE; byAddress = TRUE; } } else validIP = TRUE; if (validIP) { if (byAddress) { m_SockAddrOut.sin_addr.s_addr = lInet; m_lInet = lInet; } else { m_SockAddrOut.sin_addr.s_addr = *((unsigned long far *) hp->h_addr); m_lInet = *((unsigned long far *) hp->h_addr); } if (m_maSocketOut != NULL) { bind(m_maSocketOut, (SOCKADDR*)& m_SockAddrOut, sizeof(m_SockAddrOut)); WSAAsyncSelect(m_maSocketOut, hWnd, WM_EXTERNA, FD_READ | FD_CLOSE); } } } void sendData(char szData[], int len) { int result = sendto(m_maSocketOut, (char FAR *) &szData, len, NULL, (PSOCKADDR) &m_SockAddrOut, sizeof(m_SockAddrOut)); m_SockAddrOut.sin_addr.s_addr = INADDR_ANY; if (result < 0) { int erroCode = WSAGetLastError(); //erroCode = 10022 in Windows Vista!! } }
Important: This error code is only on Windows Vista, but not all instalations . I don't know which the exat situation, but I observed in Business and Ultimate version. Any idea? -
UDP Application on Vista: Fail on sendto functionHello, I have UDP app that works fine, except on Windows Vista. The error is WSAEINVAL (10022) on sendto function, and the package did not send :-( Anyone know this problem? Thanks, Cris.
-
GetPrivateProfileString method: problems on Windows VistaThats right... I have fixed my problem reseting the UAC configuration. But, why the UAC configuration cause this problem? []'s Cris.
-
GetPrivateProfileString method: problems on Windows VistaHello, I have a problem reading data from a INI file using GetPrivateProfileString method, only on Windows Vista. When I read from a CFG file no problem, but GetPrivateProfileString always return the default value reading a INI file located on Windows directory (C:\Windows). Anybody knows this problem? Thanks, Cris.
-
CListCtrl::SetBkImage(): how disable the image scroll?People, any idea?
-
CListCtrl::SetBkImage(): how disable the image scroll?Hello, I have setting a background image into a ListCtrl with SetBkImage() method. But the image is showed with a scroll, like the texts in the rows. How could I disable the scroll of the background image? I hope to put the image fixed in the background of ListCtrl. Any idea? Thanks, Cris.
-
How change the menu background color?Hello, I have to find how change the menu background color (menubar and menuitems), but nothing yet. On true, I want to change my dialog based app background color (I am using SetDialogBkColor() method), but the menu (I have a menu in the dialog too) continue with the default system background color. So, I only want to change the menu background color (same color of my dialog background). Could anybody help me? Thanks, Cris.
-
CMyMenu::DrawItem() - how change background color?Hello, Anybody have an idea? I have find in the net, but nothing found. Please take a look in this problem ;-) Thanks again, Cris.
-
CMyMenu::DrawItem() - how change background color?Hello, How could I change only the menu background color? I have subscribed the DrawItem method of CMyMenu class (derived from CMenu). Could any show me the code to do this? Thanks, Cris.
-
Skin Tool for VisualC++Thanks Paresh!! Do you know this tool? I am receving the message: " ---------------------------------------------------------------------------------------------- The evaluation version of the toolkit only supports DLL configurations. To purchase the full version (with static link support) please visit http://www.codejock.com ---------------------------------------------------------------------------------------------- c:\arquivos de programas\codejock software\mfc\xtreme toolkitpro v11.1.3 for visual studio 6.0\source\xttoolkitpro.h(222) : fatal error C1189: #error : This build configuration is not supported by the evaluation library " Can't I test before buy? []'s Cris.
-
Skin Tool for VisualC++Hello, Anybody knows some skin tool to became my APP skinable? I found SkinCrafter and AppFace? Anybody knows these? Thanks, Cris.
-
Choosing a printer and init printing...OK, thank you again.
-
Choosing a printer and init printing...The problem is also build a rotine for each file format.
-
Choosing a printer and init printing...It's not possible. An app cannot print a document from disc directly to printer. I should do this with the app that can read the document. :-( Thanks for your atention. []'s
-
Choosing a printer and init printing...But this file can be a .DOC file, with image included and formatted texts (bold, italic,...), then I need to build a app that the user select any file and OK. The app should send the file to a postscript printer for convert to .PS format. Can I do this, only with my app?
-
Choosing a printer and init printing...But my file can be any format, not only text file. I need to print a image too. Any other idea? []'s
-
Choosing a printer and init printing...That's right. I need to do this programatically.
-
Choosing a printer and init printing...Thanks for your help. I have a printer device and a file name on hard disc. How can start a print job passing these parameters (printer and file name)? []'s