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 638877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:46:49+00:00 2026-05-13T20:46:49+00:00

My code was working absolutely fine before the launch of iPhone SDK 3.0 ,

  • 0

My code was working absolutely fine before the launch of iPhone SDK 3.0 , I am using socket functions to send data and receive data. What changes must i make to make it compatible for 3.0+.

-(int)InitSocket:(int)nPort: (NSString*)sServer{

if(sServer == nil)
{
    return -1;
}
m_nPort = nPort;
sServerAddress = sServer;

const char* pServer = nil;
pServer = [sServer cStringUsingEncoding:NSASCIIStringEncoding];

m_nSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);


struct sockaddr_in servAddr;
memset(&servAddr, 0 , sizeof(servAddr));
servAddr.sin_family = AF_INET;
servAddr.sin_addr.s_addr = inet_addr(pServer);
servAddr.sin_port = htons(m_nPort);

pfd.fd = m_nSock;
pfd.events = POLLIN | POLLERR| POLLHUP | POLLNVAL;
pfd.revents = 0;

m_nTimeout = -1;

int f = fcntl(m_nSock, F_GETFL, 0);
fcntl(m_nSock, F_SETFL, f | O_NONBLOCK |O_NDELAY);

int opt = 1;
setsockopt(m_nSock, SOL_SOCKET, SO_KEEPALIVE, (const void*)&opt,(socklen_t)sizeof(opt));


struct timeval timeout;
fd_set wset;
FD_ZERO(&wset);
FD_SET(m_nSock, &wset);
timeout.tv_sec = 2;
timeout.tv_usec = 0;

return 0;

}

This Code for sending data

-(int)SendData:(size_t) nSize: (NSString*) buffer{

int nTotalSent = 0;
const char *pSend =  [buffer cStringUsingEncoding:NSASCIIStringEncoding];

while(nTotalSent != nSize)
{
            int nSent = send(m_nSock, (const void*)pSend+nTotalSent, nSize-nTotalSent, 0);
    if(nSent == -1)
    {
        return nSent;
    }
    nTotalSent += nSent;
}

return nTotalSent;

}

Will the above code works in iPhone SDK 3.0+ , what changes i need to employ to make it work.

Thanks

  • 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-13T20:46:49+00:00Added an answer on May 13, 2026 at 8:46 pm

    You could start by properly checking for errors. All those functions that you use return an error code if something goes wrong and you will never know.

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

Sidebar

Ask A Question

Stats

  • Questions 319k
  • Answers 319k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In order to determine if 2 collections are equal NUnit… May 14, 2026 at 12:14 am
  • Editorial Team
    Editorial Team added an answer You could use URLEncoder.encode("http://news.baidu.com/ns?word=奥巴马", "utf-8") then pass the resulting URL… May 14, 2026 at 12:14 am
  • Editorial Team
    Editorial Team added an answer It is Url.Content: ASPX: <link rel="stylesheet" href="<%= Url.Content("~/Content/style.css") %>" type="text/css"… May 14, 2026 at 12:14 am

Related Questions

I have a form, MainForm, which was working just fine and dandy until earlier
I am using Oracle 11.1.0.6.0 and ADO.NET (System.Data.OracleClient) to run a query that works
Good day all, I am having some trouble with image permissions. I am loading
I have an app where I'm trying to recursively load views. So I have
Both DataSource and DataSourceID are defined on 'grdCommunication'. Remove one definition. I just got

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.