Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4272742
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:37:07+00:00 2026-05-21T07:37:07+00:00

I am communicating to a server on socket via TCP connection in an iPhone

  • 0

I am communicating to a server on socket via TCP connection in an iPhone application. I have two text fields uTextField (for Username) & pTextField (for password) and now I want to send this request to the server. can any body tell me how can I pass the value of my text fields?
here plz check my code:

UInt8 message[] = "LOGN|rms01,123456|<END>";
                CFDataRef data = CFDataCreate(NULL, message, sizeof(message));
                CFSocketSendData(s, NULL, data, 0);
                CFRelease(data);
                NSLog(@"msg sent");

Note: My code is working good as it is, issue is to pass the values of my text fields instead of hard code. here rms01 is username and 123456 is a password LOGN is login identifier & to tell server that query end.

I know this is a stupid question but I am new in iPhone development so please help me

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:37:08+00:00Added an answer on May 21, 2026 at 7:37 am

    NSString can do most of the work for you with stringWithFormat: and dataUsingEncoding::

    NSString *username = @"username";
    NSString *password = @"password";
    
    NSString *message = [NSString stringWithFormat:@"LOGN|%@,%@|<END>", username, password];
    CFDataRef messageData = (CFDataRef)[message dataUsingEncoding:NSUTF8StringEncoding];
    
    CFSocketSendData(s, NULL, messageData, 0);
    

    Note that you do not need to release messageData.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple TCP socket client and server application. They are communicating using
I have an erlang server that will be communicating via tcp sockets with a
I have a Server communicating with multiple clients through a socket connection. In my
I have a TCP server using boost asio. I have accepted a socket connection.
I have a class that encapsulates tcp socket communications with a server. For each
Couldn't find anything about this topic. I have a Windows TCP C++ server application
I have 2 processes running in different machines which are communicating via TCP sockets.
Basically, I have a server application and associated agent process for communicating heart-beat data
I have a client-server application written in Java using CORBA for the communication. The
I'm implementing a java TCP/IP Server using ServerSocket to accept messages from clients via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.