connect function experimenting with: int Client::Connect(HWND hwnd) { // Initialize Winsock version 2.2 char message[200]; cUser user; // struct user sprintf(user.nick,"myNic"); sprintf(user.ident,"IDspoonMan"); sprintf(user.email,"vertexar@yahoo.com"); sprintf(message,"USER %s %s: %s %s \n\r", user.nick , user.email , user.ident , user.ident ); Port = 6667; WSAStartup(MAKEWORD(1,1), &wsaData); LPHOSTENT hostEntry; //store information about the server hostEntry = gethostbyname("efnet.demon.co.uk"); if(!hostEntry) { ::MessageBox(NULL,"Failed gethostbyname()","Error",0); //WSACleanup(); } // Create a new socket to make a client connection. s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); ServerAddr.sin_family = AF_INET; ServerAddr.sin_port = htons(Port); //ServerAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); ServerAddr.sin_addr = *((LPIN_ADDR)*hostEntry->h_addr_list); // Mark our socket non-blocking, and ask for asynch notifications. if (WSAAsyncSelect(s, hwnd, customClientMessage,FD_READ | FD_WRITE | FD_CONNECT | FD_CLOSE) == SOCKET_ERROR) { ::MessageBox(NULL,"TSWCCould not set to non-blocking! ", "ERROR..", MB_OK); //REPORT_PROBLEM(WSAGetLastErrorMessage("WSAAsyncSelect failed.")); return false; } int CON_ERROR = connect(s, (SOCKADDR *) &ServerAddr, sizeof(ServerAddr)); //send(s, message, strlen(message), 0); //sprintf(message,"NICK %s\n\r", user.nick); //send(s, message, strlen(message), 0); Sleep(10); send(s,"NICK mynic \n\r",15,0); send(s,"USER mynic 0 * myname \n\r",27,0); int errorCode = WSAGetLastError(); if(!CON_ERROR) return true; return false; }
using telnet i tried this and it works: o efnet.demon.co.uk 6667 NICK mynic USER mynic 0 * myname i dont see why is not working when i send it through my socket.
Adno
Posts
-
irc via socket -
irc via socketWhat do you mean, you "get" that from the server? How are you receiving that text? yes that is what i get from the server when i connect, via recv (s, buffer,bufferSize, 0); Are you sending the appropriate messages to connect to the server, as per the IRC protocol? not sure, according to this all you have to do is send commands like NICK name etc, once you are connected, but it doesn't seem to be working. http://www.irchelp.org/irchelp/rfc/rfc.html
-
irc via socketusing a socket I'm connecting to an irc server, when i do i get: NOTICE AUTH :*** Processing connection to efnet.demon.co.uk NOTICE AUTH :*** Looking up your hostname... NOTICE AUTH :*** Checking Ident NOTICE AUTH :*** Found your hostname NOTICE AUTH :*** Got Ident response this is all i get no welcome message, no matter what i send through this socket i don't get any response. then after a while i get: ERROR :Closing Link: 127.0.0.1 (Connection timed out) thanks
-
Socketsim following this article here not quite getting it to work :( http://www.codeproject.com/internet/beginningtcp\_cpp.asp Listening for connection code: int ListenOnPort(int portno, HWND hwnd) { SOCKET s; WSADATA w; int error = WSAStartup (0x0202, &w); // Fill in WSA info if (error) { return false; //For some reason we couldn't start Winsock } if (w.wVersion != 0x0202) //Wrong Winsock version? { WSACleanup (); return false; } SOCKADDR_IN addr; // The address structure for a TCP socket addr.sin_family = AF_INET; // Address family addr.sin_port = htons (portno); // Assign port to this socket //Accept a connection from any IP using INADDR_ANY //You could pass inet_addr("0.0.0.0") instead to accomplish the //same thing. If you want only to watch for a connection from a //specific IP, specify that //instead. addr.sin_addr.s_addr = htonl (INADDR_ANY); s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); // Create socket if (s == INVALID_SOCKET) { return false; //Don't continue if we couldn't create a //socket!! } if (bind(s, (LPSOCKADDR)&addr, sizeof(addr)) == SOCKET_ERROR) { //We couldn't bind (this will happen if you try to bind to the same //socket more than once) return false; } //Now we can start listening (allowing as many connections as possible to //be made at the same time using SOMAXCONN). You could specify any //integer value equal to or lesser than SOMAXCONN instead for custom //purposes). The function will not //return until a connection request is //made int tempi = listen(s, SOMAXCONN); WSAAsyncSelect (s, hwnd, MY_MESSAGE_NOTIFICATION, (FD_ACCEPT | FD_CONNECT |FD_READ | FD_CLOSE)); //Don't forget to clean up with CloseConnection()! closesocket(s); ::MessageBox(NULL,"Done Listening ", "Got Request..", MB_OK); } //-------------- Look out for the events code: switch (message) { case MY_MESSAGE_NOTIFICATION: //Is a message being sent? { switch (lParam) //If so, which one is it? { case FD_ACCEPT: ::MessageBox(NULL,"Done Listening Event", "Got Request..", MB_OK); //Connection request was made break; case FD_CONNECT: ::MessageBox(NULL,"Done Listening Event", "Got Request..", MB_OK); //Connection was made succes
-
interface programmingtake a guess :)
-
interface programminginterface IDraw { virtual void Draw() = 0; }; interface IShapeEdit { virtual void Fill (FILLTYPE fType) = 0; virtual void Inverse() = 0; virtual void Stretch(int factor) = 0; }; //------------ // C3DRect supports IDraw and IShapeEdit. class C3DRect : public IDraw, public IShapeEdit { public: C3DRect(); virtual ~C3DRect(); // IDraw virtual void Draw(); // IShapeEdit virtual void Fill (FILLTYPE fType); virtual void Inverse(); virtual void Stretch(int factor); }; //----------------------------------- // Here is the global 3D rect. C3DRect* ptheRect; // Functions to operate on the 3D rect. void CreateThe3DRect(); void DestroyThe3DRect(); Implementing CreateThe3DRect() and DestroyThe3DRect() is trivial. Simply use the new and delete keywords to create and destroy the object: // Creation function. void CreateThe3DRect() { // Create a 3d-rect. ptheRect = new C3DRect(); } // Destroy the rectangle. void DestroyThe3DRect() { // See ya! delete ptheRect; //-------------------- // This method returns interfaces to the client. bool GetInterfaceFrom3DRect(INTERFACEID iid, void** iFacePtr) { if(ptheRect == NULL){ cout << "You forgot to create the 3DRect!" << endl; return false; } if(iid == IDRAW){ // They want access to IDraw. // Cast the client's pointer to the IDraw interface of ptheRect. *iFacePtr = (IDraw*) ptheRect; return true; } if(iid == ISHAPEEDIT) { // They want access to IShapeEdit. // Cast the client's pointer to the IShapeEdit interface of ptheRect. *iFacePtr = (IShapeEdit*) ptheRect; return true; } // I have no clue what they want. *iFacePtr = NULL; // Just to be safe. cout << "C3DRect does not support interface ID: " << iid << endl<< endl; return false; } //---------------------------------------------------- int main() { bool retVal = false; IDraw* pDraw = NULL; //IDraw3* pDraw3 = NULL; IShapeEdit* pShapeEdit = NULL; CreateThe3DRect(); // Can I get the IDraw interface from object? retVal = GetInterfaceFrom3DRect(IDRAW, (void**)&pDraw); if(retVal) pDraw->Draw(); DestroyThe3DRect(); return 0; } //----- are we simply casting pointers from one type to the next here? when selecting the interface with GetInterfaceFrom3DRe
-
Just got sent this joke (hopefully not a repost...)i can imaging this being a cool advert :) animal awareness or something ...
-
Bizarrei agree with J.Dunlap, is like running onto the road to see the criminal race away only to get nocked over by some random car. the criminal bares no responsibility, i dont think.
-
Camera Capture Utility -
tray icon tooltip textthank you mark :)
-
tray icon tooltip textno change..
-
tray icon tooltip text//Shell_NotifyIcon NOTIFYICONDATA notifyData; notifyData.cbSize = sizeof(notifyData); notifyData.hWnd = hwnd; notifyData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_STATE; notifyData.uCallbackMessage = MSG_STATUSICON; notifyData.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1)); ::strcpy((char*)notifyData.szTip, "hello"); <-- not working ::strcpy((char*)notifyData.szInfo, "blablabla"); char tp [128] ; ::strcpy(tp,(char*)notifyData.szTip); //test tp gets "hello" value Shell_NotifyIcon(NIM_ADD, ¬ifyData);
instead of hello im getting gibberish on my icon ToolTip ..long string looks like chinese. something wrong with this line? ::strcpy((char*)notifyData.szTip, "hello"); thank you -
intercepting WM_CHAR message:laugh: Thank You ps have you any idea how to load and use .klc files done with Microsoft Keyboard Layout Creator
-
intercepting WM_CHAR messagei cleaned it up alot due to experimenting lol but this is it. CODE
-
intercepting WM_CHAR messagehi mark, im using "WH_GETMESSAGE" one of the options here and i should be dealing with this GetMsgProc Function right? obviously not since is not working :sigh: what tells you that im dealing with "keyboard hook proc", more importantly how do i fix it. im practicing to write a dll so i want to get my head around this hooking business. Thank You
-
intercepting WM_CHAR messageim trying to get the WM_CHAR message and this set up is not doing it. i have an edit text box in my window and all im getting is the keydown message when i type to it.
LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam){ if(code == HC_ACTION){ MSG* pMsg = (MSG*)lParam; if(pMsg->message == WM_CHAR){ int i=0; i = i +10;//test for WM_CHAR breakpoint } } return CallNextHookEx(g_KeybdHook, code, wParam, lParam); }
hook in main:g_KeybdHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, 0,GetCurrentThreadId());
thanks -
what's function?oh cool function :omg:
-
what's function?#include #include #include using namespace std; int main(void){ string bi = "1010"; //binary int result= 0; for (int i = 0; i< bi.size(); i++){ if (bi[i] == '1'){ result += pow((double)2,(double)bi.size()-i)/2; } } cout << result << endl; return 0; } that should work
-
scrollbarscreating scrollbar.... case WM_CREATE: sb1 = CreateWindowEx( 0L, // no extended styles "SCROLLBAR", // scroll bar control class (LPSTR) NULL, // text for window title bar WS_CHILD | SBS_HORZ | WS_VISIBLE, // scroll bar styles 50, // horizontal position 20, // vertical position 200, // width of the scroll bar 100, // default height hwnd, // handle to main window (HMENU) NULL, // no menu for a scroll bar hInst, // instance owning this window (LPVOID) NULL // pointer not needed ); ............. and then in the message loop: //------------------------------------------------- case WM_HSCROLL:{ int xNewPos; // new position switch (LOWORD(wParam)) { // User clicked the shaft left of the scroll box. case SB_PAGEUP: xNewPos = xCurrentScroll - 50; break; // User clicked the shaft right of the scroll box. case SB_PAGEDOWN: xNewPos = xCurrentScroll + 50; break; // User clicked the left arrow. case SB_LINEUP: xNewPos = xCurrentScroll - 5; break; // User clicked the right arrow. case SB_LINEDOWN: xNewPos = xCurrentScroll + 5; break; // User dragged the scroll box. case SB_THUMBPOSITION: xNewPos = HIWORD(wParam); break; default: xNewPos = xCurrentScroll; }; if (xNewPos == xCurrentScroll) break; xCurrentScroll = xNewPos; si.cbSize = sizeof(si); si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS ; si.nMax = 300; si.nMin = 0; si.nPage = 4; si.nPos = xCurrentScroll; SetScrollInfo(sb1, SB_HORZ, &si, true); InvalidateRect( hwnd, NULL, TRUE ); } //-------------------------------------- the new one shows over the old one. i.e the scrollbar with the height of 100 which i set up shows over the one with the default height, and dont update. The old one does update when i press the on the new. visual example, from the code above this happens. http://i3.photobucket.com/albums/y98/lamefif/scrollbar.jpg[^] many thanks
-
Rotating Bitmaps !!!!:-D:-D:-D:-D:-D:-D:-D:-D