Im back again, this time needing some winsock help. I'm building a small chat program and need some help, i called listen as you will see in the code at the end of this post, now, where do i put the accept function? I really dont know, because the client says that its getting a 10035 (WSAEWOULDBLOCK) err and dont know what to do, so here's a sinpet of code from the server and the client, if you need to see more or, you find the problem post please!(Warning un-documented code!) server: ----start server snipet----- .if uMsg==WM_INITDIALOG invoke SetFocus,eax invoke WSAStartup,101h,addr wsadata invoke socket,PF_INET,SOCK_STREAM,0 mov sock,eax invoke GetDlgItem,hWnd,IDC_STATUS invoke GetDlgItem,hWnd,IDC_WORDS invoke SetDlgItemText,hWnd,IDC_STATUS,addr Nocone invoke WSAAsyncSelect,sock, hWnd, uMsg, FD_READ+FD_ACCEPT+FD_CLOSE invoke bind,sock,addr sin,sizeof sin .ELSEIF uMsg==WM_CLOSE invoke closesocket,sock invoke WSACleanup invoke EndDialog,hWnd,NULL .ELSEIF uMsg==WM_COMMAND mov eax,wParam mov edx,wParam shr edx,16 .if dx==BN_CLICKED .if ax==IDC_LISTEN mov sin.sin_family,AF_INET ;port conversion invoke htons,Port mov sin.sin_port,ax invoke listen,sock,1 invoke SetDlgItemText,hWnd,IDC_STATUS,addr Listn .if ax==SOCKET_ERROR invoke WSAGetLastError mov dwCode,eax invoke wsprintf,Addr szString, Addr StrCtl, dwCode invoke MessageBox,hWnd,Addr szString,addr err, MB_OK .endif .elseif ax==IDC_QUIT invoke closesocket,sock invoke WSACleanup invoke EndDialog,hWnd,NULL .endif .endif .ELSEIF uMsg==WM_SOCKET invoke MessageBox,hWnd,addr so, addr befor, MB_OK invoke accept,sock,NULL,NULL mov eax,lParam .if ax==FD_ACCEPT shr eax,16 .if ax==NULL invoke MessageBox,hWnd,addr so, addr befor, MB_OK ;no errors go on ;invoke accept,sock,NULL,NULL invoke SetDlgItemText,hWnd,IDC_STATUS,addr Conection .else ;ERROR invoke WSAGetLastError mov dwCode,eax invoke wsprintf,Addr szString, Addr StrCtl, dwCode invoke MessageBox,hWnd,Addr szString,addr err, MB_OK .endif .elseif ax==FD_READ -----end server snipet----- client: -----start client snipet----- .ELSEIF uMsg==WM_COMMAND mov eax,wParam mov edx,wParam shr edx,16 .if dx==BN_CLICKED .if ax==IDC_CONNECT mov sin.sin_family,AF_INET ;port conversion invoke htons,Port mov sin.sin_port,ax invoke GetDlgItemText,hWnd,IDC_IP,addr ip,15 invoke inet_addr,addr ip mov sin.sin_addr,eax invoke connect,sock,addr sin,sizeof sin .if eax==SOCKET_ERROR invoke WSAGetLastError .if eax!=WSAEWOULDBLOCK mov dwCode,eax invoke wsprintf,Addr szString, Addr StrCtl, dwCode invoke MessageBox,hWnd,Addr szString,addr err, MB_OK .endif .endif .elseif ax==IDC_SEND invoke GetDlgItemText,hWnd,IDC_SENDT,addr sendbuf,100 invoke send,sock,sendbuf,100,0 .if eax==SOCKET_ERROR invoke MessageBox, NULL, addr befor, addr befor, MB_OK .endif .elseif ax==IDC_QUIT invoke closesocket,socket invoke WSACleanup invoke EndDialog,hWnd,NULL .endif .endif .ELSEIF uMsg==WM_SOCKET mov eax,lParam .if ax==FD_CONNECT shr eax,16 invoke WSAGetLastError .if ax==NULL ;no errors go on invoke SetDlgItemText,hWnd,IDC_STATUS,addr Conection .if eax!=WSAEWOULDBLOCK invoke WSAGetLastError mov dwCode,eax invoke wsprintf,Addr szString, Addr StrCtl, dwCode invoke MessageBox,hWnd,Addr szString,addr err, MB_OK .endif .else invoke WSAGetLastError ;this is the part where the error mov dwCode,eax ;that im getting is displayed. invoke wsprintf,Addr szString, Addr StrCtl, dwCode invoke MessageBox,hWnd,Addr szString,addr err, MB_OK ;ERROR .endif .elseif ax==FD_READ ----end client snipet------ any help would be appri
Posted on 2000-11-18 17:17:00 by rage9
Ive actually written a prog in TASM that allows you to log on and send email to a mail server - this demonstrates the send/recv concept between a client and host quite well. Get it from : http://james.ezylink.net.au
Posted on 2000-11-19 20:49:00 by James