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

  • SEARCH
  • Home
  • 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

Related Questions

This piece of code is working absolutely fine when I am executing it individually
My code is working fine, but Im getting a few problems. The first problem
I've used this code in another site I've made and it works absolutely fine
My CSS code below is working fine in Chrome, but isn't working in Firefox.
I have this code, which is working fine in FireFox, chrome and IE8 but
My code is working fine but I don't want it to fire when #stem
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
Why isn't this code working? I've been stuck on this for 2 days. public
We have the following code working for a complex rails form with checkboxes. I'm
I have this JQuery code working however I need to know whether how to

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.