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. Problem Reciving data in ftp using winsock [modified]

Problem Reciving data in ftp using winsock [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++tutorial
1 Posts 1 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.
  • D Offline
    D Offline
    darkcloud 42o
    wrote on last edited by
    #1

    Hi, Im pretty new to C++.. been messing with the standard library for a while.. but im in need of some help here.. i apologise i dont really have decent code to show.. as i said im new... Anyway.. the problem is im getting some strange imput from the command line console some after the accepting socket... heres what i get... C:\>winsock Listening on Socket USER test q▲∟¼q↔¼q^↔¼qzv½qPëV PASS test qi ¼q2è½q►=½q╡↔¼qµ@½qUSER test q▲∟¼q↔¼q^↔¼qzv½qPëV Listening on Socket Yeah.. my computer beeps and everything.. some strange mating call of FTP i presume... basically i was wondering what that is.. and how to recieve data in only regular text format after sending data... so i can process the login and other ftp commands... heres what i get in the client so far for this code... [R] Connecting to 127.0.0.1 -> IP=127.0.0.1 PORT=21 [R] Connected to 127.0.0.1 [R] 220 Welcome to my Custom FTP [R] USER test [R] 331 Password Required [R] PASS (hidden) [R] 230 Welcome to my Custom FTP. [R] SYST [R] QUIT please have a look at the code... im using devc++ and it does compile ok... without further wait.. heres what ive got so far... #include #include #include using namespace std; int accept(SOCKET AcceptSocket, SOCKET ListenSocket); int main() { int sk; WSAData wsaData; WORD wVersionRequested; wVersionRequested=MAKEWORD(2, 0); WSAStartup( wVersionRequested, &wsaData ); sockaddr_in service; service.sin_family = AF_INET; service.sin_addr.s_addr = inet_addr("127.0.0.1"); service.sin_port = htons(21); int test; while(1){ SOCKET ListenSocket; ListenSocket = socket(AF_INET, SOCK_STREAM, 0); if (bind( ListenSocket, (SOCKADDR*) &service, sizeof(service)) == SOCKET_ERROR) { cout << "bind() failed.\n"; closesocket(ListenSocket); return 1; } cout << "Listening on Socket\n"; SOCKET AcceptSocket; sk=listen( ListenSocket, 10 ); AcceptSocket = accept( ListenSocket, NULL, NULL ); test=accept(AcceptSocket, ListenSocket); #ifdef WIN32 Sleep( 5000 ); #endif if(test==2){break;} } WSACleanup(); return 0; } int accept (SOCKET AcceptSocket, SOCKET ListenSocket) { int bytesSent; int bytesRecv; int test; char sendbuf[1024] = "220 Welcome to my Custom FTP\n"; char* recvbuf = ""; char user[32]; char pass[32]; bytesSent=send( AcceptSocket, sendbuf, strlen(sendbuf), 0 );

    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