help with sockets .. client-server programming

This is a discussion on help with sockets .. client-server programming within the Linux Programming forums, part of the Platform Specific Boards category; i write small linux code just to spawn me shell when connect on it .. i use nc to connect ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    6

    help with sockets .. client-server programming

    i write small linux code just to spawn me shell when connect on it .. i use nc to connect on it ... but i want to code an client

    server just do regular things like... socket()... bind() .. listen() .. etc.etc and then execl("bin/sh"....
    I just need litle guiding for stdin and how to send that on sockets .. catch my drift ?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    6
    So the ``Hello world!'' goes to the client connected.
    Next time post your question to the Linux Programming forum. And what do you need this for? I surely hope you're not trying to write lame ``malware''... [/B]
    Sorry for my bad english .. my question was about writing a client ... i need a hint to do that, like client for telnetd but without auth.
    It isn't malware or something like that .. i am reading Beej guide to socket programing and just trying things.
    I know to write client and send mesg from comand line ./client IP_server mesg .. but i need interactive client.

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>but i need interactive client
    Then use the standard IO functions to read input from the keyboard, write the data to the socket, and then write the servers response to the screen.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    6
    Originally posted by Hammer
    >>but i need interactive client
    Then use the standard IO functions to read input from the keyboard, write the data to the socket, and then write the servers response to the screen.
    ok... i'm into that now but ...
    more problems for me ... my server can only accept one connection and after i disconnect with client server dies (cant accept connections)
    I know that it's something with fork() .... but dont have idea how to solve it.
    One more ... how to throw server in backround after i start it ? i want solution in code not just './server &'

  6. #6
    Registered User
    Join Date
    Oct 2002
    Posts
    6
    Originally posted by vVv
    I don't feel like writing you the entire thing, so take this pseudo-code as suggestion and read on the topic.
    Code:
    #include <sys/types.h>
    #include <unistd.h>
    ...
    pid_t child;
    child = fork( );
    if( child == -1 ) {
      /* error handling */
    } else if( child == 0 ) {
      if( setsid( ) != 0 ) {
        /* error handling */
      }
    } else
        return 0;
    I have been trying similar code except setsid() .. thanks vVv.
    .. and of course i dont expect whole code ... just a hint
    Thanks again !!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple Client - Server problems (Async Sockets )
    By Cpp_Noob in forum Networking/Device Communication
    Replies: 4
    Last Post: 06-19-2009, 07:12 AM
  2. Programming chat client, need some help (sockets & threads)
    By lalilulelo17 in forum Linux Programming
    Replies: 1
    Last Post: 04-19-2008, 04:01 AM
  3. server client application - (i really need your help)
    By sarahnetworking in forum C Programming
    Replies: 3
    Last Post: 03-01-2008, 09:54 PM
  4. Unicode vurses Non Unicode client server application with winsock2 query?
    By dp_76 in forum Networking/Device Communication
    Replies: 0
    Last Post: 05-16-2005, 07:26 AM
  5. Client and Server Sockets
    By Unregistered in forum C++ Programming
    Replies: 0
    Last Post: 01-09-2002, 08:53 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21