Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Urgent Requirement-Socket Programming

Urgent Requirement-Socket Programming

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++sysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Billar
    wrote on last edited by
    #1

    Dear Friends, I am using CAsyncSocket and CSocket for writting a server program. In AsyncSocket I am using virtual void OnAccept(int nErrorCode); virtual void OnClose(int nErrorCode); virtual void OnReceive(int nErrorCode); and also in Socket I am using virtual void OnAccept(int nErrorCode); virtual void OnClose(int nErrorCode); virtual void OnConnect(int nErrorCode); virtual void OnReceive(int nErrorCode); Also in the dlg.cpp file, At InitDialog I am writting m_cSocketServer.Create(4000); m_cSocketServer.Listen(); m_cAsyncSocketServer.Create(4000); m_cSocketServer.Listen(); Also at the Onbutton message I am checking and writting a message into a display like this void CMFCServerDlg::OnButtonConnection() { // TODO: この位置にコントロール通知ハンドラ用のコードを追加してください char DispBuf[256]; if(m_cSocketServer.Create(4000) && m_cSocketServer.Listen()){ sprintf(DispBuf, "Server Started"); AfxGetMainWnd()->GetDlgItem(IDC_STATIC)->SetWindowText(DispBuf); } else{ sprintf(DispBuf, "Connection Failed"); AfxGetMainWnd()->GetDlgItem(IDC_STATIC)->SetWindowText(DispBuf); } For other reference.... LRESULT CMFCServerDlg::OnAccept(WPARAM wParam, LPARAM lParam) { m_cSocketServer.Accept(m_cAsyncSocketServer); DestroyFlag = TRUE; return 0; } This is a user message send by the AsyncSocket and Socket from OnAcceptMessage.... My applicaion is very simple and with the above code it is not working. Will you please help to detect the error. Why this code is not suitable to develop a simple server. Here, I have a dialog box with one button and a text box. Button is for to start a server and text box is nothing but to display a message that server is started. Please help me to find out the solution. Thanking You in advance. Billar

    I Y 2 Replies Last reply
    0
    • B Billar

      Dear Friends, I am using CAsyncSocket and CSocket for writting a server program. In AsyncSocket I am using virtual void OnAccept(int nErrorCode); virtual void OnClose(int nErrorCode); virtual void OnReceive(int nErrorCode); and also in Socket I am using virtual void OnAccept(int nErrorCode); virtual void OnClose(int nErrorCode); virtual void OnConnect(int nErrorCode); virtual void OnReceive(int nErrorCode); Also in the dlg.cpp file, At InitDialog I am writting m_cSocketServer.Create(4000); m_cSocketServer.Listen(); m_cAsyncSocketServer.Create(4000); m_cSocketServer.Listen(); Also at the Onbutton message I am checking and writting a message into a display like this void CMFCServerDlg::OnButtonConnection() { // TODO: この位置にコントロール通知ハンドラ用のコードを追加してください char DispBuf[256]; if(m_cSocketServer.Create(4000) && m_cSocketServer.Listen()){ sprintf(DispBuf, "Server Started"); AfxGetMainWnd()->GetDlgItem(IDC_STATIC)->SetWindowText(DispBuf); } else{ sprintf(DispBuf, "Connection Failed"); AfxGetMainWnd()->GetDlgItem(IDC_STATIC)->SetWindowText(DispBuf); } For other reference.... LRESULT CMFCServerDlg::OnAccept(WPARAM wParam, LPARAM lParam) { m_cSocketServer.Accept(m_cAsyncSocketServer); DestroyFlag = TRUE; return 0; } This is a user message send by the AsyncSocket and Socket from OnAcceptMessage.... My applicaion is very simple and with the above code it is not working. Will you please help to detect the error. Why this code is not suitable to develop a simple server. Here, I have a dialog box with one button and a text box. Button is for to start a server and text box is nothing but to display a message that server is started. Please help me to find out the solution. Thanking You in advance. Billar

      I Offline
      I Offline
      includeh10
      wrote on last edited by
      #2

      there are few samples in MSDN (VC CD), you can learn from those samples, they are not complex. cheers includeh10

      B 1 Reply Last reply
      0
      • I includeh10

        there are few samples in MSDN (VC CD), you can learn from those samples, they are not complex. cheers includeh10

        B Offline
        B Offline
        Billar
        wrote on last edited by
        #3

        Hi includeh10 I don't have msdn. So if you can provide the such samples, it will be a great help to me. Waiting for your reply....... Billar

        1 Reply Last reply
        0
        • B Billar

          Dear Friends, I am using CAsyncSocket and CSocket for writting a server program. In AsyncSocket I am using virtual void OnAccept(int nErrorCode); virtual void OnClose(int nErrorCode); virtual void OnReceive(int nErrorCode); and also in Socket I am using virtual void OnAccept(int nErrorCode); virtual void OnClose(int nErrorCode); virtual void OnConnect(int nErrorCode); virtual void OnReceive(int nErrorCode); Also in the dlg.cpp file, At InitDialog I am writting m_cSocketServer.Create(4000); m_cSocketServer.Listen(); m_cAsyncSocketServer.Create(4000); m_cSocketServer.Listen(); Also at the Onbutton message I am checking and writting a message into a display like this void CMFCServerDlg::OnButtonConnection() { // TODO: この位置にコントロール通知ハンドラ用のコードを追加してください char DispBuf[256]; if(m_cSocketServer.Create(4000) && m_cSocketServer.Listen()){ sprintf(DispBuf, "Server Started"); AfxGetMainWnd()->GetDlgItem(IDC_STATIC)->SetWindowText(DispBuf); } else{ sprintf(DispBuf, "Connection Failed"); AfxGetMainWnd()->GetDlgItem(IDC_STATIC)->SetWindowText(DispBuf); } For other reference.... LRESULT CMFCServerDlg::OnAccept(WPARAM wParam, LPARAM lParam) { m_cSocketServer.Accept(m_cAsyncSocketServer); DestroyFlag = TRUE; return 0; } This is a user message send by the AsyncSocket and Socket from OnAcceptMessage.... My applicaion is very simple and with the above code it is not working. Will you please help to detect the error. Why this code is not suitable to develop a simple server. Here, I have a dialog box with one button and a text box. Button is for to start a server and text box is nothing but to display a message that server is started. Please help me to find out the solution. Thanking You in advance. Billar

          Y Offline
          Y Offline
          Yulianto
          wrote on last edited by
          #4

          I didn`t get your question. where did it not work? Do u hawe IIS or PWS? Change the port ? I`m just guessing, cause i don`t know where is the problem. So the me the detail

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups